From d6e0e5b198e8ebb472cf4eeb618f590817868ade Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Sat, 3 Jan 2015 00:43:21 +0000 Subject: [PATCH] free screens from where they were allocated --- libctru/source/gfx.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libctru/source/gfx.c b/libctru/source/gfx.c index 9047594..e7b6672 100644 --- a/libctru/source/gfx.c +++ b/libctru/source/gfx.c @@ -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);