[SDL] SDL_SetVideoMode and SDL_FreeSurface best practices?
Doug
biteme at bitbasher.net
Tue Aug 15 13:19:54 PDT 2006
I like it when my app doesn't leak memory. :P So, I'm wondering, which of these
two code snippets is the best sequence of events?
SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE );
Surface = SDL_SetVideoMode( 640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF );
// use surface here
SDL_Quit();
SDL_FreeSurface( Surface );
SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE );
Surface = SDL_SetVideoMode( 640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF );
// use surface here
SDL_FreeSurface( Surface );
SDL_Quit();
In other words, is it better to free Surface before or after SDL_Quit? Or, does
SDL_Quit delete any surfaces created by SDL_SetVideoMode automatically?
Note that I've left out any error checking code to make the code samples simple.
Thanks,
Doug.
More information about the SDL
mailing list