Closed Mem leak on DisplaFormat functions as they return a copy of the surface.
[sdlgit/SDL_perl.git] / src / Core / objects / Surface.xs
index b35484a..43bd8dc 100644 (file)
@@ -45,26 +45,14 @@ surface_new (CLASS, flags, width, height, depth, Rmask, Gmask, Bmask, Amask )
        OUTPUT:
                RETVAL
 
-int
-surface_fill_rect ( dest, dest_rect, color )
-       SDL_Surface *dest
-       SDL_Color *color
-       SDL_Rect *dest_rect
+SDL_PixelFormat *
+surface_format ( surface )
+       SDL_Surface *surface
        CODE:
-               Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b);
-               RETVAL = SDL_FillRect(dest,dest_rect,pixel);
+               char* CLASS = "SDL::PixelFormat";
+               RETVAL = surface->format;
        OUTPUT:
                RETVAL
-               
-void
-surface_update_rect ( surface, x, y, w ,h )
-       SDL_Surface *surface
-       int x
-       int y
-       int w
-       int h
-       CODE:
-               SDL_UpdateRect(surface,x,y,w,h);
 
 void
 surface_update_rects ( surface, ... )
@@ -91,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
 
@@ -100,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