]> Chaos Git - corbenik/ctrulib.git/commitdiff
free screens from where they were allocated
authorDave Murphy <davem@devkitpro.org>
Sat, 3 Jan 2015 00:43:21 +0000 (00:43 +0000)
committerDave Murphy <davem@devkitpro.org>
Sat, 3 Jan 2015 00:43:21 +0000 (00:43 +0000)
libctru/source/gfx.c

index 90475945f59e9f8cf69cbe71370b84a56413a25b..e7b667204d53742809c6f029845246ef8032f6a2 100644 (file)
@@ -97,6 +97,8 @@ void gfxWriteFramebufferInfo(gfxScreen_t screen)
        framebufferInfoHeader[0x1]=1;
 }
 
+void (*screenFree)(void *) = NULL;
+
 void gfxInit(GSP_FramebufferFormats topFormat, GSP_FramebufferFormats bottomFormat, bool vrambuffers)
 {
        void *(*screenAlloc)(size_t);
@@ -104,11 +106,12 @@ void gfxInit(GSP_FramebufferFormats topFormat, GSP_FramebufferFormats bottomForm
        if (vrambuffers)
        {
                screenAlloc=vramAlloc;
+               screenFree=vramFree;
 
        } else {
 
                screenAlloc=linearAlloc;
-
+               screenFree=linearFree;
        }
 
        gspInit();
@@ -165,16 +168,18 @@ void gfxInitDefault() {
 
 void gfxExit()
 {
+       if (screenFree == NULL ) return;
+
        // Exit event handler
        gspExitEventHandler();
 
        // Free framebuffers
-       linearFree(gfxTopRightFramebuffers[1]);
-       linearFree(gfxTopRightFramebuffers[0]);
-       linearFree(gfxBottomFramebuffers[1]);
-       linearFree(gfxBottomFramebuffers[0]);
-       linearFree(gfxTopLeftFramebuffers[1]);
-       linearFree(gfxTopLeftFramebuffers[0]);
+       screenFree(gfxTopRightFramebuffers[1]);
+       screenFree(gfxTopRightFramebuffers[0]);
+       screenFree(gfxBottomFramebuffers[1]);
+       screenFree(gfxBottomFramebuffers[0]);
+       screenFree(gfxTopLeftFramebuffers[1]);
+       screenFree(gfxTopLeftFramebuffers[0]);
 
        //unmap GSP shared mem
        svcUnmapMemoryBlock(gspSharedMemHandle, 0x10002000);