[SDL] How safe is not freeing a surface all the time?
Manuel García Cabrera
manugarciac5 at yahoo.com.ar
Thu Jun 7 22:17:50 PDT 2007
I used to loop this:
image = SDL_CreateRGBSurfaceFrom( ... );
SDL_BlitSurface(image, &rect, screen, NULL);
SDL_UpdateRect(screen,0,0,0,0);
SDL_FreeSurface(image);
I want to know if looping this is safe:
image = SDL_CreateRGBSurfaceFrom( ... );
SDL_BlitSurface(image, &rect, screen, NULL);
SDL_UpdateRect(screen,0,0,0,0);
And then calling at the end of my app a single:
SDL_FreeSurface(image);
Sam Lantinga escribió:
>> How safe is calling SDL_CreateRGBSurfaceFrom many times on a certain
>> SDL_Surface* and then doing a sigle SDL_FreeSurface at the end?
>
> SDL_CreateRGBSurfaceFrom() doesn't increment the reference count of the
> surface that you passed the pixels from, so once you free it, the surfaces
> that were created in SDL_CreateRGBSurfaceFrom() are pointing at garbage.
>
> So... if I understand you correctly... not safe at all? :)
>
> See ya,
> -Sam Lantinga, Lead Software Engineer, Blizzard Entertainment
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
More information about the SDL
mailing list