mem alloc take 2

This commit is contained in:
dborth 2008-09-27 07:57:03 +00:00
parent 264dda0965
commit 7ebc1432c0
4 changed files with 3 additions and 15 deletions

View File

@ -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;
}

View File

@ -80,6 +80,8 @@ FreeSaveBuffer ()
{
if (savebuffer != NULL)
free(savebuffer);
savebuffer = NULL;
}
/****************************************************************************

View File

@ -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;
}

View File

@ -152,7 +152,7 @@ LoadSRAM (int method, bool silent)
char filepath[1024];
int offset = 0;
AllocSaveBuffer ();
AllocSaveBuffer();
if(method == METHOD_SD || method == METHOD_USB)
{