From: Kartik Thakore Date: Fri, 16 Oct 2009 13:28:03 +0000 (-0400) Subject: Closed Mem leak on DisplaFormat functions as they return a copy of the surface. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8fb66c781c8b5bb0774800b4c41cb97fb12c5996;hp=350e894348b0c3a73f203014ba6d92cdb4f7f4ee;p=sdlgit%2FSDL_perl.git Closed Mem leak on DisplaFormat functions as they return a copy of the surface. The related docs are here http://www.libsdl.org/cgi/docwiki.cgi/SDL_DisplayFormat#head-17f6a1b691f7203226664e6323c8fd42ad5dbff1 --- diff --git a/src/Core/objects/Surface.xs b/src/Core/objects/Surface.xs index 90e8aba..43bd8dc 100644 --- a/src/Core/objects/Surface.xs +++ b/src/Core/objects/Surface.xs @@ -79,7 +79,10 @@ surface_display ( surface ) SDL_Surface *surface CODE: char* CLASS = "SDL::Surface"; - RETVAL = SDL_DisplayFormat(surface); + + SDL_Surface *new_surface = SDL_DisplayFormat(surface); + SDL_FreeSurface(surface); + RETVAL = new_surface; OUTPUT: RETVAL @@ -88,7 +91,9 @@ surface_display_alpha ( surface ) SDL_Surface *surface CODE: char* CLASS = "SDL::Surface"; - RETVAL = SDL_DisplayFormatAlpha(surface); + SDL_Surface *new_surface = SDL_DisplayFormatAlpha(surface); + SDL_FreeSurface(surface); + RETVAL = new_surface; OUTPUT: RETVAL