Jump to content
  • Advertisement
Sign in to follow this  
Sync Views

Memory question

This topic is 3655 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alot of things (expecialy the older stuff) return "const char*" . eg "const char* LastError()" Seeing as these are const so I can't edit them does this mean that they will go out of scope and get deleted for me or do I this need to delete them myself?

Share this post


Link to post
Share on other sites
Advertisement
You delete only and exactly what you new.

If you didn't allocate it, you don't delete it.

This applies to implementation of functions as well, for example, Foo * createFoo() may require you to call deleteFoo(Foo * foo), if that particular library requires you to do so.

Share this post


Link to post
Share on other sites
Read the documentation for the function in question. Ex: strdup() returns a memory block that you need to call free() on. SDL_GetError() returns a string that you don't need to clean up.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!