[SDL] Tiny memory leak in Windows directx driver

Sam Lantinga slouken at devolution.com
Tue Jul 2 21:56:00 PDT 2002


> Sam,

> just doing some memory-leak checking (for TuxPaint) and discovered an 
> 8-byte leak (surface->hwdata) on *software* DD surfaces.

> All DD surfaces have hwdata (contains pointers to DD surface interfaces).

> In 'video/SDL_surface.c', SDL_FreeSurface() only frees the hwdata
> (by calling video->FreeHWSurface()) if the surface flags indicate
> that it is a *hardware* surface.

> I propose that this be changed to a test of surface->hwdata as
> indicated below. This would be in keeping with other resource
> deallocation in this function.


> void SDL_FreeSurface (SDL_Surface *surface)
> {
> ...
> /* if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {    */
>  if ( surface->hwdata ) {
>   SDL_VideoDevice *video = current_video;
>   SDL_VideoDevice *this  = current_video;
>   video->FreeHWSurface(this, surface);
>  }
> ...
> }

Thanks, this fix is in CVS.  Can you check to make sure it doesn't break
anything else?

Thanks!
	-Sam Lantinga, Software Engineer, Blizzard Entertainment




More information about the SDL mailing list