Skip to content
1 change: 1 addition & 0 deletions src/core/jaguar.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ void JaguarDone(void)
DSPDone();
TOMDone();
JERRYDone();
m68k_done();
}

uint8_t * GetRamPtr(void)
Expand Down
18 changes: 16 additions & 2 deletions src/m68000/m68kinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,25 @@ void M68KDebugResume(void)
}


// File-scope so m68k_done() below can reset it after freeing table68k.
static uint32_t emulation_initialized = 0;

// Free process-lifetime allocations made by read_table68k(). Called
// from JaguarDone() so ASAN runs see a clean shutdown.
extern struct instr * table68k;
Comment thread
JoeMatt marked this conversation as resolved.
Outdated
void m68k_done(void)
{
if (table68k)
{
free(table68k);
table68k = NULL;
}
Comment thread
JoeMatt marked this conversation as resolved.
Outdated
emulation_initialized = 0;
}

// Pulse the RESET line on the CPU
void m68k_pulse_reset(void)
{
static uint32_t emulation_initialized = 0;

// The first call to this function initializes the opcode handler jump table
if (!emulation_initialized)
{
Expand Down
1 change: 1 addition & 0 deletions src/m68000/m68kinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ typedef enum
#define M68K_INT_ACK_SPURIOUS 0xFFFFFFFE

void m68k_pulse_reset(void);
void m68k_done(void);
int m68k_execute(int num_cycles);
void m68k_set_irq(unsigned int int_level);

Expand Down
14 changes: 14 additions & 0 deletions src/tom/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,20 @@ void GPUInit(void)
GPUReset();
}

void GPUDone(void)
{
/* Release the branch-condition LUT so process-lifetime ASAN runs
* don't report it as a leak. Safe to call without a matching
* GPUInit (free(NULL) is a no-op) and safe to re-call after a
* subsequent GPUInit (build_branch_condition_table early-outs on
* non-NULL pointer). */
if (branch_condition_table)
{
free(branch_condition_table);
branch_condition_table = NULL;
}
Comment thread
JoeMatt marked this conversation as resolved.
Outdated
}

void GPUReset(void)
{
unsigned i;
Expand Down
1 change: 1 addition & 0 deletions src/tom/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern "C" {
#define GPU_WORK_RAM_BASE 0x00F03000

void GPUInit(void);
void GPUDone(void);
void GPUReset(void);
void GPUExec(int32_t);
void GPUUpdateRegisterBanks(void);
Expand Down
1 change: 1 addition & 0 deletions src/tom/tom.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ void TOMDone(void)
{
OPDone();
BlitterDone();
GPUDone();
}


Expand Down
Loading