MMC3: Make sure to free any allocated memory when using MMC3 as an external module.
This commit is contained in:
@@ -75,6 +75,7 @@ static void M199Power(void) {
|
||||
}
|
||||
|
||||
static void M199Close(void) {
|
||||
GenMMC3Close();
|
||||
if (CHRRAM)
|
||||
FCEU_gfree(CHRRAM);
|
||||
CHRRAM = NULL;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "mapinc.h"
|
||||
#include "mmc3.h"
|
||||
|
||||
static uint8 lut[256] = {
|
||||
static const uint8 lut[256] = {
|
||||
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,
|
||||
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,
|
||||
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,
|
||||
|
||||
@@ -55,6 +55,7 @@ static DECLFW(M269Write5) {
|
||||
}
|
||||
|
||||
static void M269Close(void) {
|
||||
GenMMC3Close();
|
||||
if (CHRROM)
|
||||
FCEU_free(CHRROM);
|
||||
CHRROM = NULL;
|
||||
|
||||
@@ -110,6 +110,7 @@ static void M353Reset(void) {
|
||||
}
|
||||
|
||||
static void M353Close(void) {
|
||||
GenMMC3Close();
|
||||
if (CHRRAM)
|
||||
FCEU_gfree(CHRRAM);
|
||||
CHRRAM = NULL;
|
||||
|
||||
@@ -67,6 +67,7 @@ static DECLFW(M356Write) {
|
||||
}
|
||||
|
||||
static void M356Close(void) {
|
||||
GenMMC3Close();
|
||||
if (CHRRAM)
|
||||
FCEU_free(CHRRAM);
|
||||
CHRRAM = NULL;
|
||||
|
||||
@@ -90,6 +90,7 @@ static void M372Power(void) {
|
||||
}
|
||||
|
||||
static void M372Close(void) {
|
||||
GenMMC3Close();
|
||||
if (CHRRAM)
|
||||
FCEU_gfree(CHRRAM);
|
||||
CHRRAM = NULL;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "mapinc.h"
|
||||
#include "mmc3.h"
|
||||
|
||||
static uint8 lut[4] = { 0x00, 0x02, 0x02, 0x03 };
|
||||
static const uint8 lut[4] = { 0x00, 0x02, 0x02, 0x03 };
|
||||
|
||||
static DECLFW(UNL6035052ProtWrite) {
|
||||
EXPREGS[0] = lut[V & 3];
|
||||
|
||||
@@ -175,6 +175,10 @@ static void BS110Reset(void)
|
||||
MMC3RegReset();
|
||||
}
|
||||
static void BS110Close(void) {
|
||||
GenMMC3Close();
|
||||
if (WRAM)
|
||||
FCEU_free(WRAM);
|
||||
WRAM = NULL;
|
||||
}
|
||||
|
||||
void BS110_Init(CartInfo *info) {
|
||||
|
||||
@@ -213,6 +213,7 @@ static void Bs5652Reset(void)
|
||||
|
||||
static void Bs5652Close(void)
|
||||
{
|
||||
GenMMC3Close();
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
|
||||
@@ -162,6 +162,7 @@ static void NC7000MReset(void) {
|
||||
MMC3RegReset();
|
||||
}
|
||||
static void NC7000MClose(void) {
|
||||
GenMMC3Close();
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
|
||||
@@ -83,6 +83,7 @@ static void BMC1024CA1Power(void) {
|
||||
}
|
||||
|
||||
static void BMC1024CA1Close(void) {
|
||||
GenMMC3Close();
|
||||
if (CHRRAM)
|
||||
FCEU_gfree(CHRRAM);
|
||||
CHRRAM = NULL;
|
||||
|
||||
@@ -90,6 +90,7 @@ static void BMC810131C_Power(void) {
|
||||
}
|
||||
|
||||
static void BMC810131C_Close(void) {
|
||||
GenMMC3Close();
|
||||
if (CHRRAM)
|
||||
FCEU_gfree(CHRRAM);
|
||||
CHRRAM = NULL;
|
||||
|
||||
@@ -289,7 +289,7 @@ void GenMMC3Power(void) {
|
||||
FCEU_dwmemset(CHRRAM, 0, CHRRAMSIZE);
|
||||
}
|
||||
|
||||
static void GenMMC3Close(void) {
|
||||
void GenMMC3Close(void) {
|
||||
if (CHRRAM)
|
||||
FCEU_gfree(CHRRAM);
|
||||
if (WRAM)
|
||||
|
||||
@@ -21,6 +21,7 @@ extern void (*mwrap)(uint8 V);
|
||||
void GenMMC3Power(void);
|
||||
void GenMMC3Restore(int version);
|
||||
void MMC3RegReset(void);
|
||||
void GenMMC3Close(void);
|
||||
void FixMMC3PRG(int V);
|
||||
void FixMMC3CHR(int V);
|
||||
DECLFW(MMC3_CMDWrite);
|
||||
|
||||
@@ -61,6 +61,7 @@ static void MSHPower(void) {
|
||||
}
|
||||
|
||||
static void MSHClose(void) {
|
||||
GenMMC3Close();
|
||||
if (CHRRAM)
|
||||
FCEU_gfree(CHRRAM);
|
||||
CHRRAM = NULL;
|
||||
|
||||
@@ -76,6 +76,7 @@ static void Super24Reset(void) {
|
||||
}
|
||||
|
||||
static void Super24Close(void) {
|
||||
GenMMC3Close();
|
||||
if (CHRRAM)
|
||||
FCEU_gfree(CHRRAM);
|
||||
CHRRAM = NULL;
|
||||
|
||||
Reference in New Issue
Block a user