New answers tagged

0

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

For starters, the program doesn't actually compile without error. It's probably compiling in your environment with a warning about an unused parameter in the call to load(). In most people's environment, that would produce a warning about the unused parameter of dictionary in the signature which would be treated as an error. The root cause of that is this ...


0

I finally figured it out. It was because strlen was (word +1) and not (word) + 1. It's amazing what parentheses can do!


0

lower_word is not null terminated. Since it is being used as a string in strcasecmp that may (will?) cause unpredictable result.


0

on observing the check 50 and debug50 results, I realized that the problem was in the unload function. solution: // Unloads dictionary from memory, returning true if successful, else false bool unload(void) { node *tmp = NULL; node *cursor = NULL; //iterating over each linked list in the hash table. for(int i = 0; i < N; ...


1

The first big problems I see are in check(). Look at this line: while(cursor->next != NULL) This is going to result in every other node being skipped, among other anomalies. It should be checking cursor, not cursor->next. I'll let you figure out why. Next, there's the two free(cursor) statements in the check function. Even though you created a ...


1

It looks like an intermittent problem that's going to rear it's ugly head depending on what's in memory and what was in memory before. Since your whole code wasn't posted, I looked fairly closely at the load function. This jumps out at me: for (int i = 0; word[i]; i++) { w->word[i] = word[i]; } It looks like the code is trying to ...


Top 50 recent answers are included