diff options
author | 2010-10-04 19:45:45 +0200 | |
---|---|---|
committer | 2010-10-04 19:45:45 +0200 | |
commit | 6841f38744b045b0e2a8e2904a9beb9c1d595919 (patch) | |
tree | 40a9cbdbf17da06fc1bd22a9a7c6184984c15b96 | |
parent | 0b444640ccfd0f9d9fbcbbd4658a246833bdaf00 (diff) |
fixed several memleaks in ao plugin
-rw-r--r-- | plugins/ao/eng_psf/eng_psf2.c | 16 | ||||
-rw-r--r-- | plugins/ao/eng_psf/peops2/spu.h | 1 | ||||
-rw-r--r-- | plugins/ao/eng_psf/peops2/spu2.c | 7 | ||||
-rw-r--r-- | plugins/ao/main.c | 5 |
4 files changed, 23 insertions, 6 deletions
diff --git a/plugins/ao/eng_psf/eng_psf2.c b/plugins/ao/eng_psf/eng_psf2.c index 22059746..de9e5148 100644 --- a/plugins/ao/eng_psf/eng_psf2.c +++ b/plugins/ao/eng_psf/eng_psf2.c @@ -461,12 +461,12 @@ void *psf2_start(const char *path, uint8 *buffer, uint32 length) psf2_synth_t *s = malloc (sizeof (psf2_synth_t)); memset (s, 0, sizeof (psf2_synth_t)); - uint8 *file, *lib_decoded; + uint8 *file = NULL, *lib_decoded; uint32 irx_len; uint64 file_len, lib_raw_length, lib_len; uint8 *buf; union cpuinfo mipsinfo; - corlett_t *lib; + corlett_t *lib = NULL; loadAddr = 0x23f00; // this value makes allocations work out similarly to how they would // in Highly Experimental (as per Shadow Hearts' hard-coded assumptions) @@ -477,6 +477,10 @@ void *psf2_start(const char *path, uint8 *buffer, uint32 length) free (s); return NULL; } + if (file) { + free (file); + file = NULL; + } if (file_len > 0) printf("ERROR: PSF2 can't have a program section! ps %08x\n", (unsigned int)file_len); @@ -523,7 +527,7 @@ void *psf2_start(const char *path, uint8 *buffer, uint32 length) free (s); return NULL; } - + #if DEBUG_LOADER printf("Lib FS section: size %x bytes\n", lib->res_size); #endif @@ -531,6 +535,8 @@ void *psf2_start(const char *path, uint8 *buffer, uint32 length) num_fs++; filesys[1] = (uint8 *)lib->res_section; fssize[1] = lib->res_size; + free (lib); + lib = NULL; } // dump all files @@ -630,11 +636,15 @@ int32 psf2_stop(void *handle) { psf2_synth_t *s = handle; SPU2close(s->mips_cpu); + SPU2free(s->mips_cpu); if (s->c->lib[0] != 0) { free(s->lib_raw_file); } free(s->c); + if (s->mips_cpu) { + mips_exit (s->mips_cpu); + } free (s); return AO_SUCCESS; diff --git a/plugins/ao/eng_psf/peops2/spu.h b/plugins/ao/eng_psf/peops2/spu.h index 0400e306..e0707178 100644 --- a/plugins/ao/eng_psf/peops2/spu.h +++ b/plugins/ao/eng_psf/peops2/spu.h @@ -102,6 +102,7 @@ typedef struct spu2_state_s { //EXPORT_GCC void CALLBACK SPU2playADPCMchannel(mips_cpu_context *cpu, xa_decode_t *xap); EXPORT_GCC long CALLBACK SPU2init(mips_cpu_context *cpu, void (*callback)(unsigned char *, long, void *), void *data); +EXPORT_GCC void CALLBACK SPU2free(mips_cpu_context *cpu); EXPORT_GCC long CALLBACK SPU2open(mips_cpu_context *cpu, void *pDsp); EXPORT_GCC void CALLBACK SPU2async(mips_cpu_context *cpu, unsigned long cycle); EXPORT_GCC void CALLBACK SPU2close(mips_cpu_context *cpu); diff --git a/plugins/ao/eng_psf/peops2/spu2.c b/plugins/ao/eng_psf/peops2/spu2.c index 5b7ae050..44546170 100644 --- a/plugins/ao/eng_psf/peops2/spu2.c +++ b/plugins/ao/eng_psf/peops2/spu2.c @@ -777,6 +777,13 @@ EXPORT_GCC long CALLBACK SPU2init(mips_cpu_context *cpu, void (*callback)(unsign return 0; } +EXPORT_GCC void CALLBACK SPU2free (mips_cpu_context *cpu) { + if (cpu->spu2) { + free (cpu->spu2); + cpu->spu2 = NULL; + } +} + //////////////////////////////////////////////////////////////////////// // SETUPTIMER: init of certain buffers and threads/timers //////////////////////////////////////////////////////////////////////// diff --git a/plugins/ao/main.c b/plugins/ao/main.c index 2d2c45aa..a3c7bdc4 100644 --- a/plugins/ao/main.c +++ b/plugins/ao/main.c @@ -31,8 +31,8 @@ #include "ao.h" #include "eng_protos.h" -#define trace(...) { fprintf(stderr, __VA_ARGS__); } -//#define trace(fmt,...) +//#define trace(...) { fprintf(stderr, __VA_ARGS__); } +#define trace(fmt,...) /* file types */ static uint32 type; @@ -235,7 +235,6 @@ ao_identify (char *buffer) { void * ao_start (uint32 type, const char *path, uint8 *buffer, uint32 size) { - printf ("ao_start %d %p %d\n", type, buffer, size); return (*types[type].start)(path, buffer, size); } |