Hot answers tagged


Initially you have declared node *table[N] as global pointer. As you might have already guessed, all global variables/ pointers are set to default values.(In this case, each pointer is set to NULL). So head = table[hash_index]; // It's still NULL When you do head->next, you're trying to de-reference NULL which results in seg-fault.


There is a memory leak: 472 bytes in 1 blocks are still reachable in loss record 1 of 1 ==1123== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/ ==1123== by 0x4A27AAD: __fopen_internal (iofopen.c:65) ==1123== by 0x4A27AAD: fopen@@GLIBC_2.2.5 (iofopen.c:86) ==1123== by 0x401ABE: load (dictionary.c:64)...


First, since the global declarations and other code that comes at the top of the file weren't included, I've had to guess at some things to test the code. I suspect that sumstring, used in the hash function, is declared as a global. If so, that's a big problem here. Since it's not initialized inside of the hash function, it is also not reset between calls. ...


Let's take the easy one first. Think about how check_buffer is populated. The for loop copies every char from word. The problem is that this does NOT copy the end of string marker, \0 to the end of the string! The printf, strlen, and so many other functions depend on this. Without it, printf is going to just keep printing chars until it finds 0x00 as ...

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