strdup-free or delete

Started by
3 comments, last by Zahlman 17 years, 10 months ago
What should we use on pointer returned by strdup. Should I use free or delete. I don't know what(new or malloc) has been used to allocate memory in strdup. Any idea?
Advertisement
You should use free since it is from a C library.
well, you should use std::string and forget about all that nonsense
Boder is correct. In the future check the documentation for such functions as it should say which deallocation method to use.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
If it's possible to ask this question in your program (i.e. you're using C++), then you almost certainly shouldn't be using strdup() in the first place.

This topic is closed to new replies.

Advertisement