mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-27 21:14:21 +01:00
reduce memory fragmentation with static savebuffer
This commit is contained in:
parent
f3851f8c69
commit
ead421820b
@ -35,7 +35,8 @@
|
|||||||
#include "filebrowser.h"
|
#include "filebrowser.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
|
||||||
unsigned char * savebuffer = NULL;
|
unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN(32);
|
||||||
|
static mutex_t bufferLock = LWP_MUTEX_NULL;
|
||||||
FILE * file; // file pointer - the only one we should ever use!
|
FILE * file; // file pointer - the only one we should ever use!
|
||||||
bool unmountRequired[9] = { false, false, false, false, false, false, false, false, false };
|
bool unmountRequired[9] = { false, false, false, false, false, false, false, false, false };
|
||||||
bool isMounted[9] = { false, false, false, false, false, false, false, false, false };
|
bool isMounted[9] = { false, false, false, false, false, false, false, false, false };
|
||||||
@ -419,10 +420,11 @@ ParseDirectory(int method)
|
|||||||
void
|
void
|
||||||
AllocSaveBuffer ()
|
AllocSaveBuffer ()
|
||||||
{
|
{
|
||||||
while(savebuffer != NULL) // save buffer is in use
|
if(bufferLock == LWP_MUTEX_NULL)
|
||||||
usleep(50); // wait for it to be free
|
LWP_MutexInit(&bufferLock, false);
|
||||||
|
|
||||||
savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE);
|
if(bufferLock != LWP_MUTEX_NULL)
|
||||||
|
LWP_MutexLock(bufferLock);
|
||||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,10 +435,8 @@ AllocSaveBuffer ()
|
|||||||
void
|
void
|
||||||
FreeSaveBuffer ()
|
FreeSaveBuffer ()
|
||||||
{
|
{
|
||||||
if (savebuffer != NULL)
|
if(bufferLock != LWP_MUTEX_NULL)
|
||||||
free(savebuffer);
|
LWP_MutexUnlock(bufferLock);
|
||||||
|
|
||||||
savebuffer = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -38,7 +38,7 @@ u32 LoadSzFile(char * filepath, unsigned char * rbuffer);
|
|||||||
u32 SaveFile(char * buffer, char *filepath, u32 datasize, int method, bool silent);
|
u32 SaveFile(char * buffer, char *filepath, u32 datasize, int method, bool silent);
|
||||||
u32 SaveFile(char * filepath, u32 datasize, int method, bool silent);
|
u32 SaveFile(char * filepath, u32 datasize, int method, bool silent);
|
||||||
|
|
||||||
extern unsigned char * savebuffer;
|
extern unsigned char savebuffer[SAVEBUFFERSIZE];
|
||||||
extern FILE * file;
|
extern FILE * file;
|
||||||
extern bool unmountRequired[];
|
extern bool unmountRequired[];
|
||||||
extern bool isMounted[];
|
extern bool isMounted[];
|
||||||
|
Loading…
Reference in New Issue
Block a user