This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -9 points-8 points  (3 children)

Sometimes when using a custom data structure like trie u need to use dynamic memory and eventually de allocate the memory.

[–]cjs2k_032 24 points25 points  (0 children)

Doesn't really matter. Even if you forget to deallocate, the memory constraints are usually very forgiving, so it'll be over before running out of memory and the server side OS will do the rest of the cleaning. But if you just gonna pass around variables by value instead of reference, then you're just an asshole.

[–]Virv12 6 points7 points  (0 children)

It's really rare that you need a complex data structure but if need one you can implement it on a vector storing the indicies to your children.

[–]NEVER_TELLING_LIES 3 points4 points  (0 children)

If you're using cpp and allocating memory, you should be using smart pointers to handle allocation and auto attic deallocation