reduce memory fragmentation. fixes out of memory crashes (eg: after many save state loads)

This commit is contained in:
dborth 2009-10-27 06:00:22 +00:00
parent a7b43100c4
commit 851402beff

View File

@ -974,7 +974,7 @@ static int MenuGameSelection()
// populate initial directory listing
OpenGameList();
gameBrowser.ResetState();
gameBrowser.fileList[0]->SetState(STATE_SELECTED);
gameBrowser.TriggerUpdate();
@ -1032,6 +1032,7 @@ static int MenuGameSelection()
HaltParseThread(); // halt parsing
HaltGui();
ResetBrowser();
mainWindow->Remove(&titleTxt);
mainWindow->Remove(&buttonWindow);
mainWindow->Remove(&gameBrowser);
@ -1624,6 +1625,8 @@ static int MenuGameSaves(int action)
len = strlen(Memory.ROMFilename);
// find matching files
AllocSaveBuffer();
for(i=0; i < browser.numEntries; i++)
{
len2 = strlen(browserList[i].filename);
@ -1654,10 +1657,9 @@ static int MenuGameSaves(int action)
{
sprintf(scrfile, "%s%s/%s.png", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, tmp);
AllocSaveBuffer();
memset(savebuffer, 0, SAVEBUFFERSIZE);
if(LoadFile(scrfile, SILENT))
saves.previewImg[j] = new GuiImageData(savebuffer);
FreeSaveBuffer();
}
snprintf(filepath, 1024, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, saves.filename[j]);
if (stat(filepath, &filestat) == 0)
@ -1671,6 +1673,7 @@ static int MenuGameSaves(int action)
}
}
FreeSaveBuffer();
saves.length = j;
if(saves.length == 0 && action == 0)
@ -1790,6 +1793,7 @@ static int MenuGameSaves(int action)
mainWindow->Remove(&saveBrowser);
mainWindow->Remove(&w);
mainWindow->Remove(&titleTxt);
ResetBrowser();
return menu;
}