unload returns false and i am not sure why.... when i run Valgrind i get this:
HEAP SUMMARY:
==7885== in use at exit: 608 bytes in 2 blocks
==7885== total heap usage: 143,096 allocs, 143,094 frees, 8,023,416 bytes allocated
==7885== 56 bytes in 1 blocks are still reachable in loss record 1 of 2
LEAK SUMMARY:
==7885== definitely lost: 0 bytes in 0 blocks
==7885== indirectly lost: 0 bytes in 0 blocks
==7885== possibly lost: 0 bytes in 0 blocks
==7885== still reachable: 608 bytes in 2 blocks
==7885== suppressed: 0 bytes in 0 blocks
i dont understand where that 608 bytes leak is from.....
// Unloads dictionary from memory, returning true if successful else false
bool unload(void)
{
node *current[N - 1];
node *temp[N - 1];
for (int i = 0; i < N; i++)
{
if (table[i] != NULL)
{
//initialize the current node pointer to the table`s head
current[i] = table[i];
//initialize the temporary node pointer to the same node as current node pointer
temp[i] = current[i];
//delete nodes in the list and free the memory
while (current[i] != NULL)
{
current[i] = current[i]->next;
free(temp[i]);
temp[i] = current[i];
}
}
}
//check that memory has been freed
for (int i = 0; i < N; i++)
{
if (table[i] != NULL)
{
return false;
}
}
return true;
}