Closed Mem leak on DisplaFormat functions as they return a copy of the surface.
Kartik Thakore [Fri, 16 Oct 2009 13:28:03 +0000 (09:28 -0400)]
The related docs are here http://www.libsdl.org/cgi/docwiki.cgi/SDL_DisplayFormat#head-17f6a1b691f7203226664e6323c8fd42ad5dbff1

src/Core/objects/Surface.xs

index 90e8aba..43bd8dc 100644 (file)
@@ -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