mirror of https://github.com/mgba-emu/mgba.git
Core: Fix some memory leaks
This commit is contained in:
parent
f7a9fe8e64
commit
3a834d564d
|
@ -74,6 +74,7 @@ static void _GBCoreDeinit(struct mCore* core) {
|
|||
mCheatDeviceDestroy(gbcore->cheatDevice);
|
||||
}
|
||||
free(gbcore->cheatDevice);
|
||||
mCoreConfigFreeOpts(&core->opts);
|
||||
free(core);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -92,6 +92,7 @@ static void _GBACoreDeinit(struct mCore* core) {
|
|||
mCheatDeviceDestroy(gbacore->cheatDevice);
|
||||
}
|
||||
free(gbacore->cheatDevice);
|
||||
mCoreConfigFreeOpts(&core->opts);
|
||||
free(core);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue