I'm using a trie data structure to tackle the spell checker. The code works fine and is almost as fast as the staff's implementation. Even check50 is happy about it.
But when I run valgrind it throws up this stuff:
==2707==
==2707== HEAP SUMMARY:
==2707== in use at exit: 84,835,408 bytes in 757,459 blocks
==2707== total heap usage: 757,462 allocs, 3 frees, 84,836,224 bytes allocated
==2707==
==2707== LEAK SUMMARY:
==2707== definitely lost: 0 bytes in 0 blocks
==2707== indirectly lost: 0 bytes in 0 blocks
==2707== possibly lost: 0 bytes in 0 blocks
==2707== still reachable: 84,835,408 bytes in 757,459 blocks
==2707== suppressed: 0 bytes in 0 blocks
==2707== Reachable blocks (those to which a pointer was found) are not shown.
==2707== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==2707==
==2707== For counts of detected and suppressed errors, rerun with: -v
==2707== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Here is my source code: https://gist.github.com/anonymous/669d315165110705acb8
Can anyone point out what's wrong?
---------- UPDATE ----------
Here is my updated working code of the freeMem
function:
bool freeMem(node* pntr)
{
// free each not null pointer
for (int i = 0; i < MAX; i++)
{
if (pntr->next[i] != NULL)
freeMem(pntr->next[i]);
}
// free the node itself
free(pntr);
return true;
}