[SDL] HARD WARE SURFACES

Jukka-Pekka Manninen jmanninen at digitalchocolate.com
Fri Oct 5 02:55:37 PDT 2007


Hi

> -----Original Message-----
> On Behalf Of Patricia Curtis
> I am freeing the surfaces before i create new surfaces as you can see.
> So what am i doing wrong?

SDL_DisplayFormatAlpha does not free the surface you give it, so your
code leaks two surfaces at these lines, one from SDL_CreateRGBSurface
and one from IMG_Load:

> 	gLevel	=
>
SDL_DisplayFormatAlpha(SDL_CreateRGBSurface(SDL_HWSURFACE,SCREEN_WID
> TH,SCREEN_HEIGHT,32,RMASK,
> GMASK, BMASK, AMASK));
> 	SDL_Surface * TempSurface			=
> 	SDL_DisplayFormatAlpha(IMG_Load(PathName));

Instead use something like

SDL_Surface* temp = SDL_CreateRGBSurface(...);
gLevel = SDL_DisplayFormatAlpha(temp);
SDL_FreeSurface(temp);

Make a similar change for the second case, and you shouldn't lose any
more memory in that function.

-- 
Jukka-Pekka Manninen



More information about the SDL mailing list