Jump to content
  • Advertisement
Sign in to follow this  
uncle_rico

re-assigning SDL Surfaces

This topic is 4622 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

Hey there, I was just wondering if it was unwise to re-assign an SDL Surface like this:
SDL_Surface * mySurface;
mySurface = SDL_LoadBMP("foo.bmp");

// do stuff here

mySurface = SDL_LoadBMP("goo.bmp");

Is that, like, memory leak city or does SDL take care of it for me?

Share this post


Link to post
Share on other sites
Advertisement
SDL will not take care of it for you. its very lazy...

use SDL_FreeSurface( /*surface to be freed*/ ); when you are done using a surface. but dont use it on the video surface.

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
SDL will not take care of it for you. its very lazy...

use SDL_FreeSurface( /*surface to be freed*/ ); when you are done using a surface. but dont use it on the video surface.


Ditto.

You... you... LAZY API! *Points to SDL!*

It won't free it because it might not be the root pointer, it might be a pointer to something else that is pointed to by another pointer. If it was deleted, the other pointer would point to the one-way ticket to garbage-land.

DO NOT use it on your main surface!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!