GBA: Make sure unloading only frees if needed and always zeroes variable

This commit is contained in:
Jeffrey Pfau 2015-06-22 01:32:49 -07:00
parent 051af279c9
commit 86a36853ed
1 changed files with 2 additions and 3 deletions

View File

@ -97,14 +97,13 @@ static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) {
}
void GBAUnloadROM(struct GBA* gba) {
if (gba->pristineRom == gba->memory.rom) {
gba->memory.rom = 0;
} else {
if (gba->memory.rom && gba->pristineRom != gba->memory.rom) {
if (gba->yankedRomSize) {
gba->yankedRomSize = 0;
}
mappedMemoryFree(gba->memory.rom, SIZE_CART0);
}
gba->memory.rom = 0;
if (gba->romVf) {
gba->romVf->unmap(gba->romVf, gba->pristineRom, gba->pristineRomSize);