Fix some on-exit memory leaks

This commit is contained in:
OV2 2017-10-13 22:24:30 +02:00
parent fc224c0df7
commit 17b3a81419
6 changed files with 34 additions and 11 deletions

View File

@ -153,6 +153,7 @@ SMP::SMP() {
} }
SMP::~SMP() { SMP::~SMP() {
delete[] apuram;
} }
} }

View File

@ -229,7 +229,8 @@ bool ConfigFile::LoadFile(const char *filename){
n=filename; n=filename;
n2=strrchr(n, '/'); if(n2!=NULL) n=n2+1; n2=strrchr(n, '/'); if(n2!=NULL) n=n2+1;
n2=strrchr(n, '\\'); if(n2!=NULL) n=n2+1; n2=strrchr(n, '\\'); if(n2!=NULL) n=n2+1;
LoadFile(new fStream(s), n); fStream fS(s);
LoadFile(&fS, n);
CLOSE_FSTREAM(s); CLOSE_FSTREAM(s);
ret = true; ret = true;
} else { } else {

View File

@ -333,7 +333,8 @@ static bool try_load_config_file (const char *fname, ConfigFile &conf)
if (fp) if (fp)
{ {
fprintf(stdout, "Reading config file %s.\n", fname); fprintf(stdout, "Reading config file %s.\n", fname);
conf.LoadFile(new fStream(fp)); fStream fS(fp);
conf.LoadFile(&fS);
CLOSE_FSTREAM(fp); CLOSE_FSTREAM(fp);
return (true); return (true);
} }

View File

@ -536,6 +536,23 @@ void InitRenderFilters(void)
} }
} }
void DeInitRenderFilters()
{
if (ntsc) {
delete ntsc;
}
if (BlendBuf) {
delete[] BlendBuf;
}
if (xbrz_thread_sync_data) {
delete[] xbrz_thread_sync_data;
delete[] xbrz_sync_handles;
}
S9xBlit2xSaIFilterDeinit();
S9xBlitHQ2xFilterDeinit();
}
#define R5G6B5 // windows port uses RGB565 #define R5G6B5 // windows port uses RGB565
#ifdef R5G6B5 #ifdef R5G6B5

View File

@ -208,5 +208,6 @@ void RenderMethod(SSurface Src, SSurface Dst, RECT *);
void SelectRenderMethod(); void SelectRenderMethod();
void InitRenderFilters(); void InitRenderFilters();
void DeInitRenderFilters();
#endif #endif

View File

@ -326,6 +326,7 @@ HANDLE SoundEvent;
ExtList* valid_ext=NULL; ExtList* valid_ext=NULL;
void MakeExtFile(void); void MakeExtFile(void);
void LoadExts(void); void LoadExts(void);
void ClearExts(void);
static bool ExtensionIsValid(const TCHAR *filename); static bool ExtensionIsValid(const TCHAR *filename);
extern FILE *trace_fs; extern FILE *trace_fs;
@ -3702,15 +3703,16 @@ loop_exit:
Memory.Deinit(); Memory.Deinit();
S9xGraphicsDeinit(); ClearExts();
S9xDeinitAPU();
WinDeleteRecentGamesList ();
DeinitS9x();
#ifdef CHECK_MEMORY_LEAKS DeInitRenderFilters();
_CrtDumpMemoryLeaks();
#endif S9xGraphicsDeinit();
return msg.wParam; S9xDeinitAPU();
WinDeleteRecentGamesList ();
DeinitS9x();
return msg.wParam;
} }
void FreezeUnfreezeDialog(bool8 freeze) void FreezeUnfreezeDialog(bool8 freeze)
@ -7048,7 +7050,7 @@ void LoadExts(void)
curr->compressed=true; curr->compressed=true;
if(strlen(buffer)>1) if(strlen(buffer)>1)
{ {
curr->extension=new TCHAR[strlen(buffer)-1]; curr->extension=new TCHAR[strlen(buffer)];
_tcsncpy(curr->extension, _tFromChar(buffer), strlen(buffer)-1); _tcsncpy(curr->extension, _tFromChar(buffer), strlen(buffer)-1);
curr->extension[strlen(buffer)-1]='\0'; curr->extension[strlen(buffer)-1]='\0';
} }