mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-12-24 18:21:50 +01:00
fix a rather nasty mem leak with savebuffer
This commit is contained in:
parent
f15890e169
commit
dfc7ddd8e3
@ -18,7 +18,6 @@
|
||||
#include "menudraw.h"
|
||||
|
||||
extern SCheatData Cheat;
|
||||
extern unsigned char savebuffer[];
|
||||
|
||||
/****************************************************************************
|
||||
* NGCLoadCheatFile
|
||||
|
@ -17,21 +17,15 @@
|
||||
#include <string.h>
|
||||
|
||||
#ifdef WII_DVD
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#include <di/di.h>
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "menudraw.h"
|
||||
#include "snes9xGX.h"
|
||||
#include "unzip.h"
|
||||
|
||||
extern int offset;
|
||||
extern int selection;
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
extern int maxfiles;
|
||||
u64 dvddir = 0;
|
||||
u64 dvdrootdir = 0;
|
||||
int dvddirlength = 0;
|
||||
|
@ -29,13 +29,6 @@
|
||||
|
||||
FILE * filehandle;
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
extern char output[16384];
|
||||
extern int offset;
|
||||
extern int selection;
|
||||
extern char currentdir[MAXPATHLEN];
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
|
||||
/****************************************************************************
|
||||
* fat_is_mounted
|
||||
* to check whether FAT media are detected.
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <string.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <sys/dir.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#ifdef WII_DVD
|
||||
extern "C" {
|
||||
@ -33,7 +34,6 @@ extern "C" {
|
||||
#include "menudraw.h"
|
||||
#include "video.h"
|
||||
#include "aram.h"
|
||||
#include "filesel.h"
|
||||
#include "smbop.h"
|
||||
#include "fileop.h"
|
||||
#include "memcardop.h"
|
||||
@ -55,16 +55,20 @@ int hasloaded = 0;
|
||||
// Global file entry table
|
||||
FILEENTRIES filelist[MAXFILES];
|
||||
|
||||
unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN (32);
|
||||
unsigned char *savebuffer = NULL;
|
||||
|
||||
/****************************************************************************
|
||||
* ClearSaveBuffer ()
|
||||
* Clear the savebuffer
|
||||
* Allocate and clear the savebuffer
|
||||
***************************************************************************/
|
||||
void
|
||||
ClearSaveBuffer ()
|
||||
{
|
||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||
if (savebuffer)
|
||||
free(savebuffer);
|
||||
|
||||
savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE);
|
||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* softdev July 2006
|
||||
* crunchy2 May 2007
|
||||
* Michniewski 2008
|
||||
* Michniewski 2008
|
||||
* Tantric August 2008
|
||||
*
|
||||
* filesel.h
|
||||
@ -14,7 +14,9 @@
|
||||
#ifndef _NGCFILESEL_
|
||||
#define _NGCFILESEL_
|
||||
|
||||
#define SAVEBUFFERSIZE ((512 * 1024) + 2048 + 64 + 4 + 4)
|
||||
#include <unistd.h>
|
||||
|
||||
#define SAVEBUFFERSIZE (512 * 1024)
|
||||
#define MAXJOLIET 255
|
||||
#define MAXDISPLAY 54
|
||||
|
||||
@ -29,6 +31,11 @@ typedef struct
|
||||
|
||||
#define MAXFILES 2000 // Restrict to 2000 files per dir
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
extern unsigned char *savebuffer;
|
||||
extern int offset;
|
||||
extern int selection;
|
||||
extern char currentdir[MAXPATHLEN];
|
||||
extern int maxfiles;
|
||||
|
||||
void ClearSaveBuffer ();
|
||||
int OpenROM (int method);
|
||||
|
@ -40,7 +40,6 @@
|
||||
extern void S9xSRTCPreSaveState ();
|
||||
extern void NGCFreezeStruct ();
|
||||
extern bool8 S9xUnfreezeGame (const char *filename);
|
||||
extern unsigned char savebuffer[];
|
||||
|
||||
static int bufoffset;
|
||||
|
||||
|
@ -17,18 +17,6 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "snes9x.h"
|
||||
#include "memmap.h"
|
||||
#include "debug.h"
|
||||
#include "cpuexec.h"
|
||||
#include "ppu.h"
|
||||
#include "apu.h"
|
||||
#include "display.h"
|
||||
#include "gfx.h"
|
||||
#include "soundux.h"
|
||||
#include "spc700.h"
|
||||
#include "spc7110.h"
|
||||
|
||||
#include "snes9xGX.h"
|
||||
#include "video.h"
|
||||
#include "menudraw.h"
|
||||
@ -39,10 +27,10 @@
|
||||
#include "preferences.h"
|
||||
#include "memcardop.h"
|
||||
#include "fileop.h"
|
||||
#include "filesel.h"
|
||||
|
||||
#define VERIFBUFFERSIZE 65536
|
||||
static u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
||||
extern unsigned char savebuffer[];
|
||||
unsigned char verifbuffer[VERIFBUFFERSIZE] ATTRIBUTE_ALIGN (32);
|
||||
card_dir CardDir;
|
||||
card_file CardFile;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "smbop.h"
|
||||
#include "filesel.h"
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
extern int currconfig[4];
|
||||
|
||||
// button map configurations
|
||||
@ -120,7 +119,7 @@ int
|
||||
preparePrefsData (int method)
|
||||
{
|
||||
int offset = 0;
|
||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||
ClearSaveBuffer ();
|
||||
|
||||
// add save icon and comments for Memory Card saves
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
|
@ -35,14 +35,6 @@ unsigned int SMBTimer = 0;
|
||||
SMBCONN smbconn;
|
||||
#define ZIPCHUNK 16384
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
extern char output[16384];
|
||||
extern int offset;
|
||||
extern int selection;
|
||||
extern char currentdir[MAXPATHLEN];
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* InitializeNetwork
|
||||
* Initializes the Wii/GameCube network interface
|
||||
@ -281,7 +273,6 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
|
||||
ClearSaveBuffer ();
|
||||
return boffset;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "smbop.h"
|
||||
#include "filesel.h"
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
extern int padcal;
|
||||
extern unsigned short gcpadmap[];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user