Memory leakage in create()

Am having some memory leakage problem when I try to move to the next children of my trie when create() is called and don’t understand why.

Is there anything wrong with : root->children[index] = create();

Where index is just the position of the i-th character of my text. Something like : [*text - ‘a’]

Without knowing what you did that is hard to answer. However there is one important thing you should check for: If you have a pointer to a struct which contains pointers as fields it is not enough to just free the pointer to the struct, you also have to free all the fields (and if they contain pointers as fields those need to be freed as well, and so on and so forth)


  1. You should not post code from your project in the forum. We are supposed to work alone on it.
  2. Freeing the nodes doesn’t free their children and so forth. That is your problem right now.

Sorry and thanks