Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
problem with freeing data
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Richard Bos, post: 3466060"] This is wrong; you want free(tmp); here. But that's probably not what's causing your problem. That depends. If item->root->value is a char *, it doesn't. If it's a char[], it does. But you have failed to show us two critical parts of your code: - the definition of a stack, and that of stack's member root; - the code where you put your words _in_ your stack, in particular, how you declare the memory for each root's value string. If you malloc() memory for each word separately before you push them onto your stack, and don't manipulate that address before you push it on (or, say, free() it in between), you should be able to free() it. OTOH, if you get the memory for each word from part of a single malloc(), or from an automatic ("local") variable, or any number of other possibilities, you not only do not need to free() it, but shouldn't. What the solution to your problem is depends on the two bits of code I mentioned above. Richard [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
problem with freeing data
Top