[SDL] Tiny memory leak in Windows directx driver

John Popplewell john at johnnypops.demon.co.uk
Tue Jul 2 21:05:01 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);
 }
...
}


cheers,
John.





More information about the SDL mailing list