[SDL] Tiny memory leak in Windows directx driver

John Popplewell john at johnnypops.demon.co.uk
Wed Jul 3 17:41:02 PDT 2002


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

OK.

Examined SDL_CreateRGBSurface() which does most surface creation.
It always sets surface->hwdata = NULL.

Examined XXX_AllocHWSurface() for each driver and
the ones that succeed make sure that surface->hwdata is
non-NULL and freeable by calling XXX_FreeHWSurface().

Examined XXX_FreeHWSurface() for each driver and
the ones that do anything 'free' up private stuff and then
set surface->hwdata = NULL.

Functions that do format conversion (or change screen mode)
*seem* to leave surface->hwdata alone.

Looks like it is safe, :-)

cheers,
John.


----- Original Message -----
From: "Sam Lantinga" <slouken at devolution.com>
To: <sdl at libsdl.org>
Sent: Wednesday, July 03, 2002 5:55 AM
Subject: Re: [SDL] Tiny memory leak in Windows directx driver


> > 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
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl





More information about the SDL mailing list