Skip to content

Commit

Permalink
cleanup screenshot memory management.
Browse files Browse the repository at this point in the history
  • Loading branch information
dborth committed Mar 2, 2019
1 parent 19f8899 commit fac58f9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
9 changes: 2 additions & 7 deletions source/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,8 +1527,7 @@ static int MenuGame()
delete gameScreenImg;
delete gameScreen;
gameScreen = NULL;
free(gameScreenPng);
gameScreenPng = NULL;
ClearScreenshot();
if(GCSettings.AutoloadGame) {
ExitApp();
}
Expand Down Expand Up @@ -4890,11 +4889,7 @@ MainMenu (int menu)
if(gameScreen)
delete gameScreen;

if(gameScreenPng)
{
free(gameScreenPng);
gameScreenPng = NULL;
}
ClearScreenshot();

// wait for keys to be depressed
while(MenuRequested())
Expand Down
1 change: 0 additions & 1 deletion source/vbagx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ int main(int argc, char *argv[])
savebuffer = (unsigned char *)malloc(SAVEBUFFERSIZE);
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY)*MAX_BROWSER_SIZE);
#endif
gameScreenPng = (u8 *)malloc(512*1024);
InitGUIThreads();

bool autoboot = false;
Expand Down
10 changes: 10 additions & 0 deletions source/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,16 @@ void TakeScreenshot()
}
}

void ClearScreenshot()
{
if(gameScreenPng)
{
gameScreenPngSize = 0;
free(gameScreenPng);
gameScreenPng = NULL;
}
}

/****************************************************************************
* ResetVideo_Menu
*
Expand Down
1 change: 1 addition & 0 deletions source/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void StopGX();
void ResetVideo_Emu();
void ResetVideo_Menu();
void TakeScreenshot();
void ClearScreenshot();
void Menu_Render();
void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF );
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled);
Expand Down

0 comments on commit fac58f9

Please sign in to comment.