SDL: in the SDL 2.0 interface code, we use a fake surface as our vidsurface, so we should be freeing it

This commit is contained in:
Alam Ed Arias 2016-05-10 18:20:14 -04:00
parent 70a72baabc
commit a529dca69f
2 changed files with 11 additions and 8 deletions

View file

@ -372,7 +372,7 @@ else
# build a normal optimised version
WINDRESFLAGS = -DNDEBUG
CFLAGS+=-O2
#CFLAGS+=-O2
endif
CFLAGS+=-g $(OPTS) $(M5) $(WINDRESFLAGS)

View file

@ -251,6 +251,11 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
{
SDL_FreeSurface(vidSurface);
}
if (vid.buffer)
{
free(vid.buffer);
vid.buffer = NULL;
}
SDL_PixelFormatEnumToMasks(sw_texture_format, &bpp, &rmask, &gmask, &bmask, &amask);
vidSurface = SDL_CreateRGBSurface(0, width, height, bpp, rmask, gmask, bmask, amask);
}
@ -1654,12 +1659,10 @@ static void Impl_VideoSetupBuffer(void)
{
vid.rowbytes = vid.width * vid.bpp;
vid.direct = NULL;
vid.buffer = malloc(vid.rowbytes*vid.height*NUMSCREENS);
if (vid.buffer)
{
memset(vid.buffer,0x00,vid.rowbytes*vid.height*NUMSCREENS);
}
else
free(vid.buffer);
vid.buffer = calloc(vid.rowbytes*vid.height, NUMSCREENS);
if (!vid.buffer)
{
I_Error("%s", M_GetText("Not enough memory for video buffer\n"));
}
@ -1766,7 +1769,6 @@ void I_StartupGraphics(void)
//Impl_SetWindowName("SRB2 "VERSIONSTRING);
VID_SetMode(VID_GetModeForSize(BASEVIDWIDTH, BASEVIDHEIGHT));
vid.buffer = NULL; // For software mode
vid.width = BASEVIDWIDTH; // Default size for startup
vid.height = BASEVIDHEIGHT; // BitsPerPixel is the SDL interface's
vid.recalc = true; // Set up the console stufff
@ -1816,7 +1818,8 @@ void I_ShutdownGraphics(void)
icoSurface = NULL;
if (render_soft == oldrendermode)
{
vidSurface = NULL; //Alam: SDL_Video system free vidSurface for me
if (vidSurface) SDL_FreeSurface(vidSurface);
vidSurface = NULL;
if (vid.buffer) free(vid.buffer);
vid.buffer = NULL;
if (bufSurface) SDL_FreeSurface(bufSurface);