From 7ebc1432c00c24f5a77e6d9ca6668b4ddb1fbb46 Mon Sep 17 00:00:00 2001 From: dborth Date: Sat, 27 Sep 2008 07:57:03 +0000 Subject: [PATCH] mem alloc take 2 --- source/ngc/fileop.cpp | 8 -------- source/ngc/filesel.cpp | 2 ++ source/ngc/smbop.cpp | 6 ------ source/ngc/sram.cpp | 2 +- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/source/ngc/fileop.cpp b/source/ngc/fileop.cpp index 7ef3b19..dbad8c3 100644 --- a/source/ngc/fileop.cpp +++ b/source/ngc/fileop.cpp @@ -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; } diff --git a/source/ngc/filesel.cpp b/source/ngc/filesel.cpp index 769a231..03af313 100644 --- a/source/ngc/filesel.cpp +++ b/source/ngc/filesel.cpp @@ -80,6 +80,8 @@ FreeSaveBuffer () { if (savebuffer != NULL) free(savebuffer); + + savebuffer = NULL; } /**************************************************************************** diff --git a/source/ngc/smbop.cpp b/source/ngc/smbop.cpp index 4c5baa7..c09fb0a 100644 --- a/source/ngc/smbop.cpp +++ b/source/ngc/smbop.cpp @@ -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; } diff --git a/source/ngc/sram.cpp b/source/ngc/sram.cpp index 7f09546..e862f43 100644 --- a/source/ngc/sram.cpp +++ b/source/ngc/sram.cpp @@ -152,7 +152,7 @@ LoadSRAM (int method, bool silent) char filepath[1024]; int offset = 0; - AllocSaveBuffer (); + AllocSaveBuffer(); if(method == METHOD_SD || method == METHOD_USB) {