0

I've completed the pset5 and got all the check50 marks correct, except the valgrind one. What is weird is that Valgrind also say that i've freed everything correctly. Here is the error message that I get, could you tell me why do I get these errors ? Thanks !

==1479== ERROR SUMMARY: 12007 errors from 1 contexts (suppressed: 0 from 0)

(12007 is the number of buckets in my hashtable)

   // Unloads dictionary from memory, returning true if successful else false
bool unload(void)
{
    for (int i = 0; i <= N; i++)
    {
        node *cursor = hashtable[i];
        while(cursor != NULL)
        {
        node *head = hashtable[i];
        node *tmp = cursor;
        cursor = cursor->next;
        free(tmp);
        }
    }
    return true;
}
0
1

You're out of bounds:

for (int i = 0; i <= N; i++) // Runs N + 1 times

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .