0

See the code below. I initially had some segmentation fault issues, but now everything compiles OK and valgrind indicates no issues. However, running check50, the output indicates that my program isn't catching any of the misspelled words. I have checked it on a small text like "cat.txt" and it works there. It doesn't appear to be related to the case of a word, as far as I can tell. Help please!

Edited: answer below, edited out rest of the code to show only the problem section :)

// Unloads dictionary from memory, returning true if successful, else false
bool unload(void)
{
    // Iterate across the array of linked lists
    for (int i = 0; i < N; i++)
    {
        for (node *tmp = table[i]->next, *breadcrumb = table[i]->next; tmp != NULL; tmp = breadcrumb)
        {
            breadcrumb = breadcrumb->next;
            free(tmp);
        }
    }
    return true;
    return false;
}
0
0

Check it with the small dictionary. Spoiler: The unload function will seg fault here

    for (node *tmp = table[i]->next, *breadcrumb = table[i]->next; tmp != NULL; tmp = breadcrumb)

if there are any unpopulated indexes. If an index is unpopulated, there is no table[i]=>next.

1
  • Aghhhh! I was looking everywhere besides unload - I figured any issues there would be caught in valgrind'ing the large dictionary and wouldn't cause check50 to indicate misspelled words were uncaught. Thank you so much for the advice, DinoCoderSaurus! – GreenOneDream Apr 15 at 14:38

You must log in to answer this question.

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