Valgrind is finding memory leaks but i can't seem to pinpoint them, i'm hope-full someone here can help me:
main calls are Dictionary* dictionary = initDictionary();
Valgrind is finding memory leaks but i can't seem to pinpoint them, i'm hope-full someone here can help me:
main calls are Dictionary* dictionary = initDictionary();
Your initDictionary
doesn't return the pointer dictionary
anywhere.
That means when you do
Dictionary* dictionary = initDictionary();
the value of dictionary
will be indeterminate (seemingly random or garbage), and dereferencing this pointer or passing it to free
will result in undefined behavior.
You solve this by adding a simple
return dictionary;
at the end of the initDictionary
function.
If your compiler doesn't warn you about not returning anything from the function, you need to enable more verbose warnings. Using gcc
or clang
I recommend the options -Wall -Wextra -Wpedantic
when building. For MSVC use /W4
.