mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-12-25 02:31:50 +01:00
mem alloc take 2
This commit is contained in:
parent
264dda0965
commit
7ebc1432c0
@ -223,8 +223,6 @@ LoadBufferFromFAT (char *filepath, bool silent)
|
||||
int boffset = 0;
|
||||
int read = 0;
|
||||
|
||||
AllocSaveBuffer ();
|
||||
|
||||
handle = fopen (filepath, "rb");
|
||||
|
||||
if (handle <= 0)
|
||||
@ -246,8 +244,6 @@ LoadBufferFromFAT (char *filepath, bool silent)
|
||||
|
||||
fclose (handle);
|
||||
|
||||
FreeSaveBuffer ();
|
||||
|
||||
return boffset;
|
||||
}
|
||||
|
||||
@ -259,8 +255,6 @@ SaveBufferToFAT (char *filepath, int datasize, bool silent)
|
||||
{
|
||||
FILE *handle;
|
||||
|
||||
AllocSaveBuffer ();
|
||||
|
||||
if (datasize)
|
||||
{
|
||||
handle = fopen (filepath, "wb");
|
||||
@ -276,7 +270,5 @@ SaveBufferToFAT (char *filepath, int datasize, bool silent)
|
||||
fwrite (savebuffer, 1, datasize, handle);
|
||||
fclose (handle);
|
||||
}
|
||||
|
||||
FreeSaveBuffer ();
|
||||
return datasize;
|
||||
}
|
||||
|
@ -80,6 +80,8 @@ FreeSaveBuffer ()
|
||||
{
|
||||
if (savebuffer != NULL)
|
||||
free(savebuffer);
|
||||
|
||||
savebuffer = NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -246,8 +246,6 @@ SaveBufferToSMB (char *filepath, int datasize, bool silent)
|
||||
int wrote = 0;
|
||||
int boffset = 0;
|
||||
|
||||
AllocSaveBuffer();
|
||||
|
||||
smbfile =
|
||||
SMB_OpenFile (SMBPath(filepath), SMB_OPEN_WRITING | SMB_DENY_NONE,
|
||||
SMB_OF_CREATE | SMB_OF_TRUNCATE, smbconn);
|
||||
@ -275,8 +273,6 @@ SaveBufferToSMB (char *filepath, int datasize, bool silent)
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
|
||||
FreeSaveBuffer();
|
||||
|
||||
return boffset;
|
||||
}
|
||||
|
||||
@ -288,9 +284,7 @@ SaveBufferToSMB (char *filepath, int datasize, bool silent)
|
||||
int
|
||||
LoadBufferFromSMB (char *filepath, bool silent)
|
||||
{
|
||||
AllocSaveBuffer();
|
||||
int result = LoadBufferFromSMB((char *)savebuffer, filepath, silent);
|
||||
FreeSaveBuffer();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ LoadSRAM (int method, bool silent)
|
||||
char filepath[1024];
|
||||
int offset = 0;
|
||||
|
||||
AllocSaveBuffer ();
|
||||
AllocSaveBuffer();
|
||||
|
||||
if(method == METHOD_SD || method == METHOD_USB)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user