I wish i could understand better the application of malloc and calloc, i was using malloc to allocate memory for the root in my code and had the following error on valgrind:
==20066== Conditional jump or move depends on uninitialised value(s) ==20066== at 0x423344: destroy (dictionary.c:146) ==20066== by 0x42321C: unload (dictionary.c:138) ==20066== by 0x4214C4: main (speller.c:152) ==20066== Uninitialised value was created by a heap allocation ==20066== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==20066== by 0x422A2D: load (dictionary.c:70) ==20066== by 0x4208F2: main (speller.c:40) ==20066== Helping with... ==20066== Conditional jump or move depends on uninitialised value(s) Looks like you're trying to use a variable that might not have a value? Take a closer look at line 88 of
After changing to calloc, everything worked well, why? Whats the difference?