SDL HWSURFACE freeing patch

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Archaemic
Posts: 38
Joined: Sun Mar 18, 2007 7:23 am

SDL HWSURFACE freeing patch

Post by Archaemic »

While trying to do some fancy stuff using the GU in conjunction with SDL, I noticed that it was impossible to SDL_FreeSurface a hardware surface. After doing some research, I noticed that SDL will only call PSP_FreeHWSurface if surface->hwdata is non-zero. It will also call free on surface->pixels if it is non-zero after calling FreeHWSurface, which obviously won't work if the pixels pointer points to something that isn't in the heap. Therefore, I have created this small patch:

Code: Select all

--- src/video/psp/SDL_pspvideo.c        (revision 2361)
+++ src/video/psp/SDL_pspvideo.c        (working copy)
@@ -515,11 +515,13 @@
 
        surface->pitch = pitch;
        surface->flags |= SDL_HWSURFACE;
+       surface->hwdata = (void*)1; /* Hack to make SDL realize it's a HWSURFACE when freeing */
        return 0;
 }
 static void PSP_FreeHWSurface(_THIS, SDL_Surface *surface)
 {
        vidmem_free(surface->pixels);
+       surface->pixels = NULL;
        return;
 }
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

applie in rev 2366, thanks
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Post by danzel »

Thanks Archaemic!!!!
Post Reply