use the correct c++ deleters

This commit is contained in:
Ian Curtis 2018-01-06 11:19:04 +00:00
parent 19e6aab1fa
commit dc3048df24
2 changed files with 21 additions and 30 deletions

View file

@ -90,6 +90,14 @@
#define DPRINTF(a, ...) #define DPRINTF(a, ...)
#endif #endif
#ifndef SAFE_DELETE
#define SAFE_DELETE(p) delete (p); (p) = NULL;
#endif
#ifndef SAFE_ARRAY_DELETE
#define SAFE_ARRAY_DELETE(x) delete[] x; x = NULL;
#endif
using namespace SMUDP; using namespace SMUDP;
static int(*Runnet68kCB)(int cycles); static int(*Runnet68kCB)(int cycles);
@ -1225,6 +1233,8 @@ bool CNetBoard::Init(UINT8 * netRAMPtr, UINT8 *netBufferPtr)
CNetBoard::CNetBoard(const Util::Config::Node &config) : m_config(config) CNetBoard::CNetBoard(const Util::Config::Node &config) : m_config(config)
{ {
memoryPool = NULL; memoryPool = NULL;
bank = NULL;
ct = NULL;
netRAM = NULL; netRAM = NULL;
netBuffer = NULL; netBuffer = NULL;
Buffer = NULL; Buffer = NULL;
@ -1232,7 +1242,6 @@ CNetBoard::CNetBoard(const Util::Config::Node &config) : m_config(config)
CommRAM = NULL; CommRAM = NULL;
ioreg = NULL; ioreg = NULL;
ctrlrw = NULL; ctrlrw = NULL;
bank = NULL;
CodeReady = false; CodeReady = false;
test_irq = 0; test_irq = 0;
@ -1242,31 +1251,17 @@ CNetBoard::CNetBoard(const Util::Config::Node &config) : m_config(config)
CNetBoard::~CNetBoard(void) CNetBoard::~CNetBoard(void)
{ {
if (memoryPool != NULL) SAFE_ARRAY_DELETE(memoryPool);
{ SAFE_ARRAY_DELETE(bank);
delete[] memoryPool; SAFE_ARRAY_DELETE(ct);
memoryPool = NULL;
}
netRAM = NULL; netRAM = NULL;
netBuffer = NULL; netBuffer = NULL;
Buffer = NULL; Buffer = NULL;
RAM = NULL; RAM = NULL;
CommRAM = NULL; CommRAM = NULL;
ioreg = NULL; ioreg = NULL;
ctrlrw = NULL; ctrlrw = NULL;
if (bank != NULL)
{
delete bank;
bank = NULL;
}
if (ct != NULL)
{
delete ct;
ct = NULL;
}
/*if (int5 == true) /*if (int5 == true)
{ {
@ -1290,9 +1285,6 @@ bool CNetBoard::RunFrame(void)
return true; return true;
} }
M68KSetContext(&M68K); M68KSetContext(&M68K);
/*if (int5 == false) /*if (int5 == false)

View file

@ -54,7 +54,6 @@ private:
UINT8 *ioreg; UINT8 *ioreg;
UINT8 *ctrlrw; UINT8 *ctrlrw;
UINT8 *Buffer; UINT8 *Buffer;
UINT8 *Buffer2;
UINT8 *RAM; UINT8 *RAM;
UINT8 *ct; UINT8 *ct;