1

There are a number of problems in this code. For starters, it's generating a seg fault in freelist. Fixing that leads to an infinite loop, indicating issues elsewhere. Additionally, it seems to be finding that every word is misspelled. All of these issues are likely intertwined. This will be an excellent learning experience in debugging! My suggestion at ...


1

I suspect the "conditional" is in printf. str is not properly null terminated.


1

Solved all problems: reachable memory - in linked list added a new item in the end: iterate to the last item in list (not to null, but the last which refers to allocate memory for new word in the list, add the word, and next -> null free temporary node also met with some errors, like: ==1281== ==1281== HEAP SUMMARY: ==1281== in use at exit: 0 ...


1

It looks like most, if not all of the issues arise from one problem. In the load function, near the bottom, I found this: free(newnode); What happens when you free the node that you just created??? Doesn't it destroy the node that was just created at that address??? Copying the address to another location doesn't copy the node. So, if you have a dozen ...


1

The load function works perfectly I'm afraid I'm gonna have to disagree. You're calling malloc twice when the list is empty. So that's one node per list that you can effectively never free, as the pointer to that node is immediately orphaned. As for the unload function. You problems are limited to this section: struct node *current_table = table[i]; ...


1

The bug is in your unload function. You return after cleaning up just 1 list. But you have 26 of them to get through. The outer loop is also out of bounds. You iterate up to N + 1 for some reason. // Unloads dictionary from memory, returning true if successful, else false bool unload(void) { for (int i = 0; i < (N + 1); i++) // Out of bounds. Should ...


1

It's a very subtle "possible" error that valgrind detected. When I ran it with the small dictionary, I get this: ==224== Conditional jump or move depends on uninitialised value(s) ==224== at 0x401CB1: unload (dictionary.c:145) ==224== by 0x40175F: main (speller.c:152) ==224== Uninitialised value was created by a heap allocation ==224== at ...


1

The uninitialised value comes from load. Are you setting both members of the node in all cases? I don't see where you set your new node's next pointer in all cases.


Only top voted, non community-wiki answers of a minimum length are eligible