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)

    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?

1 Answer 1


Without seeing the code involved, it's just a guess, but I'd bet that whatever you're allocating memory for has a pointer in it. Malloc only allocates memory without initializing anything, while calloc will go ahead and set default values of 0 or NULL for everything allocated.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Makes sense Cliff, thanks a lot! Commented Jul 11, 2018 at 22:19

You must log in to answer this question.

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