Core: Fix some memory leaks

This commit is contained in:
Jeffrey Pfau 2016-09-07 11:04:31 -07:00
parent f7a9fe8e64
commit 3a834d564d
5 changed files with 11 additions and 3 deletions

View File

@ -74,6 +74,7 @@ static void _GBCoreDeinit(struct mCore* core) {
mCheatDeviceDestroy(gbcore->cheatDevice);
}
free(gbcore->cheatDevice);
mCoreConfigFreeOpts(&core->opts);
free(core);
}

View File

@ -221,6 +221,11 @@ void GBApplyPatch(struct GB* gb, struct Patch* patch) {
void GBDestroy(struct GB* gb) {
GBUnloadROM(gb);
if (gb->biosVf) {
gb->biosVf->close(gb->biosVf);
gb->biosVf = 0;
}
GBMemoryDeinit(gb);
GBVideoDeinit(&gb->video);
GBSIODeinit(&gb->sio);

View File

@ -92,6 +92,7 @@ static void _GBACoreDeinit(struct mCore* core) {
mCheatDeviceDestroy(gbacore->cheatDevice);
}
free(gbacore->cheatDevice);
mCoreConfigFreeOpts(&core->opts);
free(core);
}

View File

@ -140,6 +140,8 @@ void GBADestroy(struct GBA* gba) {
if (gba->biosVf) {
gba->biosVf->unmap(gba->biosVf, gba->memory.bios, SIZE_BIOS);
gba->biosVf->close(gba->biosVf);
gba->biosVf = 0;
}
GBAMemoryDeinit(gba);

View File

@ -406,9 +406,8 @@ void GameController::openGame(bool biosOnly) {
if (!m_bios.isNull() && m_useBios) {
VFile* bios = VFileDevice::open(m_bios, O_RDONLY);
if (bios) {
// TODO: Lifetime issues?
m_threadContext.core->loadBIOS(m_threadContext.core, bios, 0);
if (bios && !m_threadContext.core->loadBIOS(m_threadContext.core, bios, 0)) {
bios->close(bios);
}
}