added wrapper around places that uses malloc to use FCEU_dmalloc, for debugging purpose if the need comes up
This commit is contained in:
parent
90695b00ac
commit
0d63ef203a
|
@ -30,8 +30,8 @@
|
|||
#include "fceu.h"
|
||||
#include "file.h"
|
||||
#include "cart.h"
|
||||
#include "memory.h"
|
||||
#include "driver.h"
|
||||
#include "utils/memory.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -163,7 +163,7 @@ static void CheatMemErr(void)
|
|||
static int AddCheatEntry(char *name, uint32 addr, uint8 val, int compare, int status, int type)
|
||||
{
|
||||
struct CHEATF *temp;
|
||||
if(!(temp=(struct CHEATF *)malloc(sizeof(struct CHEATF))))
|
||||
if(!(temp=(struct CHEATF *)FCEU_dmalloc(sizeof(struct CHEATF))))
|
||||
{
|
||||
CheatMemErr();
|
||||
return(0);
|
||||
|
@ -248,7 +248,8 @@ void FCEU_LoadGameCheats(FILE *override)
|
|||
char *neo=&tbuf[4+2+2+1+1+1];
|
||||
if(sscanf(tbuf,"%04x%*[:]%02x%*[:]%02x",&addr,&val,&compare)!=3)
|
||||
continue;
|
||||
namebuf=(char *)malloc(strlen(neo)+1);
|
||||
if (!(namebuf=(char *)FCEU_dmalloc(strlen(neo)+1)))
|
||||
return;
|
||||
strcpy(namebuf,neo);
|
||||
}
|
||||
else
|
||||
|
@ -256,7 +257,8 @@ void FCEU_LoadGameCheats(FILE *override)
|
|||
char *neo=&tbuf[4+2+1+1];
|
||||
if(sscanf(tbuf,"%04x%*[:]%02x",&addr,&val)!=2)
|
||||
continue;
|
||||
namebuf=(char *)malloc(strlen(neo)+1);
|
||||
if (!(namebuf=(char *)FCEU_dmalloc(strlen(neo)+1)))
|
||||
return;
|
||||
strcpy(namebuf,neo);
|
||||
}
|
||||
|
||||
|
@ -364,7 +366,7 @@ int FCEUI_AddCheat(const char *name, uint32 addr, uint8 val, int compare, int ty
|
|||
{
|
||||
char *t;
|
||||
|
||||
if(!(t=(char *)malloc(strlen(name)+1)))
|
||||
if(!(t=(char *)FCEU_dmalloc(strlen(name)+1)))
|
||||
{
|
||||
CheatMemErr();
|
||||
return(0);
|
||||
|
@ -660,7 +662,7 @@ static int InitCheatComp(void)
|
|||
{
|
||||
uint32 x;
|
||||
|
||||
CheatComp=(uint16*)malloc(65536*sizeof(uint16));
|
||||
CheatComp=(uint16*)FCEU_dmalloc(65536*sizeof(uint16));
|
||||
if(!CheatComp)
|
||||
{
|
||||
CheatMemErr();
|
||||
|
@ -949,4 +951,4 @@ void UpdateFrozenList(void)
|
|||
//FCEU_printf("Address %d: %d \n",x,FrozenAddresses[x]); //Debug
|
||||
}
|
||||
//FCEUI_DispMessage("FrozenCount: %d",0,FrozenAddressCount);//Debug
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include <ctype.h>
|
||||
|
||||
#include "conddebug.h"
|
||||
#include "types.h"
|
||||
#include "utils/memory.h"
|
||||
|
||||
// Next non-whitespace character in string
|
||||
char next;
|
||||
|
@ -93,7 +95,9 @@ Condition* InfixOperator(const char** str, Condition(*nextPart(const char**)), i
|
|||
return 0;
|
||||
}
|
||||
|
||||
mid = (Condition*)malloc(sizeof(Condition));
|
||||
mid = (Condition*)FCEU_dmalloc(sizeof(Condition));
|
||||
if (!mid)
|
||||
return NULL;
|
||||
memset(mid, 0, sizeof(Condition));
|
||||
|
||||
mid->lhs = t;
|
||||
|
@ -317,9 +321,13 @@ Condition* Primitive(const char** str, Condition* c)
|
|||
/* Handle * and / operators */
|
||||
Condition* Term(const char** str)
|
||||
{
|
||||
Condition* t = (Condition*)malloc(sizeof(Condition));
|
||||
Condition* t1;
|
||||
Condition* t;
|
||||
Condition* t1;
|
||||
Condition* mid;
|
||||
|
||||
t = (Condition*)FCEU_dmalloc(sizeof(Condition));
|
||||
if (!t)
|
||||
return NULL;
|
||||
|
||||
memset(t, 0, sizeof(Condition));
|
||||
|
||||
|
@ -335,7 +343,9 @@ Condition* Term(const char** str)
|
|||
|
||||
scan(str);
|
||||
|
||||
t1 = (Condition*)malloc(sizeof(Condition));
|
||||
if (!(t1 = (Condition*)FCEU_dmalloc(sizeof(Condition))))
|
||||
return NULL;
|
||||
|
||||
memset(t1, 0, sizeof(Condition));
|
||||
|
||||
if (!Primitive(str, t1))
|
||||
|
@ -345,7 +355,9 @@ Condition* Term(const char** str)
|
|||
return 0;
|
||||
}
|
||||
|
||||
mid = (Condition*)malloc(sizeof(Condition));
|
||||
if (!(mid = (Condition*)FCEU_dmalloc(sizeof(Condition))))
|
||||
return NULL;
|
||||
|
||||
memset(mid, 0, sizeof(Condition));
|
||||
|
||||
mid->lhs = t;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "version.h"
|
||||
#include "fceu.h"
|
||||
#include "driver.h"
|
||||
#include "utils/memory.h"
|
||||
|
||||
static char *aboutString = 0;
|
||||
|
||||
|
@ -43,7 +44,9 @@ FCEU TAS+ - Luke Gustafson\n\
|
|||
const char *compilerString = FCEUD_GetCompilerString();
|
||||
|
||||
//allocate the string and concatenate the template with the compiler string
|
||||
aboutString = (char*)malloc(strlen(aboutTemplate) + strlen(compilerString) + 1);
|
||||
sprintf(aboutString,"%s%s",aboutTemplate,compilerString);
|
||||
if (!(aboutString = (char*)FCEU_dmalloc(strlen(aboutTemplate) + strlen(compilerString) + 1)))
|
||||
return NULL;
|
||||
|
||||
sprintf(aboutString,"%s%s",aboutTemplate,compilerString);
|
||||
return aboutString;
|
||||
}
|
||||
|
|
|
@ -135,6 +135,8 @@ int checkCondition(const char* condition, int num)
|
|||
{
|
||||
watchpoint[num].cond = c;
|
||||
watchpoint[num].condText = (char*)malloc(strlen(condition) + 1);
|
||||
if (!watchpoint[num].condText)
|
||||
return 0;
|
||||
strcpy(watchpoint[num].condText, condition);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "hq3x.h"
|
||||
|
||||
#include "../../types.h"
|
||||
|
||||
#include "../../utils/memory.h"
|
||||
#include "nes_ntsc.h"
|
||||
|
||||
nes_ntsc_t* nes_ntsc;
|
||||
|
@ -108,12 +108,12 @@ int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int efx, int
|
|||
|
||||
}
|
||||
|
||||
nes_ntsc = (nes_ntsc_t*) malloc( sizeof (nes_ntsc_t) );
|
||||
nes_ntsc = (nes_ntsc_t*) FCEU_dmalloc( sizeof (nes_ntsc_t) );
|
||||
|
||||
if ( nes_ntsc ) {
|
||||
nes_ntsc_init( nes_ntsc, &ntsc_setup, b, 2 );
|
||||
|
||||
ntscblit = (uint8*)malloc(256*257*b*multi); //Need to add multiplier for larger sizes
|
||||
ntscblit = (uint8*)FCEU_dmalloc(256*257*b*multi); //Need to add multiplier for larger sizes
|
||||
}
|
||||
|
||||
} // -Video Modes Tag-
|
||||
|
@ -121,7 +121,7 @@ int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int efx, int
|
|||
{
|
||||
int multi = ((specfilt == 2) ? 2 * 2 : 3 * 3);
|
||||
|
||||
specbuf8bpp = (uint8*)malloc(256*240*multi); //mbg merge 7/17/06 added cast
|
||||
specbuf8bpp = (uint8*)FCEU_dmalloc(256*240*multi); //mbg merge 7/17/06 added cast
|
||||
|
||||
} // -Video Modes Tag-
|
||||
else if(specfilt == 1 || specfilt == 4) // hq2x and hq3x
|
||||
|
@ -157,8 +157,8 @@ int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int efx, int
|
|||
// End iffy code
|
||||
}
|
||||
// -Video Modes Tag-
|
||||
if(specfilt == 1) specbuf32bpp = (uint32*)malloc(256*240*4*sizeof(uint32)); //mbg merge 7/17/06 added cast
|
||||
else if(specfilt == 4) specbuf32bpp = (uint32*)malloc(256*240*9*sizeof(uint32)); //mbg merge 7/17/06 added cast
|
||||
if(specfilt == 1) specbuf32bpp = (uint32*)FCEU_dmalloc(256*240*4*sizeof(uint32)); //mbg merge 7/17/06 added cast
|
||||
else if(specfilt == 4) specbuf32bpp = (uint32*)FCEU_dmalloc(256*240*9*sizeof(uint32)); //mbg merge 7/17/06 added cast
|
||||
}
|
||||
|
||||
efx=0;
|
||||
|
@ -173,7 +173,7 @@ int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int efx, int
|
|||
else
|
||||
hq2x_InitLUTs();
|
||||
|
||||
specbuf=(uint16*)malloc(256*240*sizeof(uint16)); //mbg merge 7/17/06 added cast
|
||||
specbuf=(uint16*)FCEU_dmalloc(256*240*sizeof(uint16)); //mbg merge 7/17/06 added cast
|
||||
}
|
||||
|
||||
silt = specfilt;
|
||||
|
@ -188,16 +188,16 @@ int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int efx, int
|
|||
if(efx&FVB_BLUR)
|
||||
{
|
||||
if(Bpp==2)
|
||||
palettetranslate=(uint32 *)malloc(65536*4);
|
||||
palettetranslate=(uint32 *)FCEU_dmalloc(65536*4);
|
||||
else if(Bpp>=3)
|
||||
palettetranslate=(uint32 *)malloc(65536*4);
|
||||
palettetranslate=(uint32 *)FCEU_dmalloc(65536*4);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Bpp==2)
|
||||
palettetranslate=(uint32*)malloc(65536*4);
|
||||
palettetranslate=(uint32*)FCEU_dmalloc(65536*4);
|
||||
else if(Bpp>=3)
|
||||
palettetranslate=(uint32*)malloc(256*4);
|
||||
palettetranslate=(uint32*)FCEU_dmalloc(256*4);
|
||||
}
|
||||
|
||||
if(!palettetranslate)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "sdl.h"
|
||||
#include "sdl-opengl.h"
|
||||
#include "../common/vidblit.h"
|
||||
#include "../../utils/memory.h"
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
|
@ -213,7 +214,7 @@ InitOpenGL(int l,
|
|||
{
|
||||
if(!(efx&2)) // Don't want to print out a warning message in this case...
|
||||
FCEU_printf("Paletted texture extension not found. Using slower texture format...\n");
|
||||
HiBuffer=malloc(4*256*256);
|
||||
HiBuffer=FCEU_malloc(4*256*256);
|
||||
memset(HiBuffer,0x00,4*256*256);
|
||||
#ifndef LSB_FIRST
|
||||
InitBlitToHigh(4,0xFF000000,0xFF0000,0xFF00,efx&2,0,0);
|
||||
|
@ -246,7 +247,7 @@ InitOpenGL(int l,
|
|||
p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,ipolate?GL_LINEAR:GL_NEAREST);
|
||||
p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,ipolate?GL_LINEAR:GL_NEAREST);
|
||||
|
||||
buf=(uint8*)malloc(256*(256*2)*4);
|
||||
buf=(uint8*)FCEU_dmalloc(256*(256*2)*4);
|
||||
|
||||
for(y=0;y<(256*2);y++)
|
||||
for(x=0;x<256;x++)
|
||||
|
@ -259,7 +260,7 @@ InitOpenGL(int l,
|
|||
}
|
||||
p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 256, (scanlines==2)?256*4:512, 0,
|
||||
GL_RGBA,GL_UNSIGNED_BYTE,buf);
|
||||
free(buf);
|
||||
FCEU_dfree(buf);
|
||||
}
|
||||
p_glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "sdl.h"
|
||||
|
||||
#include "../common/configSys.h"
|
||||
#include "../../utils/memory.h"
|
||||
|
||||
extern Config *g_config;
|
||||
|
||||
static volatile int *s_Buffer = 0;
|
||||
|
@ -122,7 +124,9 @@ InitSound()
|
|||
if (s_BufferSize < spec.samples * 2)
|
||||
s_BufferSize = spec.samples * 2;
|
||||
|
||||
s_Buffer = (int *)malloc(sizeof(int) * s_BufferSize);
|
||||
s_Buffer = (int *)FCEU_dmalloc(sizeof(int) * s_BufferSize);
|
||||
if (!s_Buffer)
|
||||
return 0;
|
||||
s_BufferRead = s_BufferWrite = s_BufferIn = 0;
|
||||
|
||||
//printf("SDL Size: %d, Internal size: %d\n",spec.samples,s_BufferSize);
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "../../fceu.h"
|
||||
#include "../../version.h"
|
||||
|
||||
#include "../../utils/memory.h"
|
||||
|
||||
#include "sdl-icon.h"
|
||||
#include "dface.h"
|
||||
|
||||
|
@ -650,7 +652,7 @@ BlitScreen(uint8 *XBuf)
|
|||
if(!result || resultsize != width*height*3*2)
|
||||
{
|
||||
if(result) free(result);
|
||||
result = (unsigned char*) malloc(resultsize = width*height*3*2);
|
||||
result = (unsigned char*) FCEU_dmalloc(resultsize = width*height*3*2);
|
||||
}
|
||||
switch(s_curbpp)
|
||||
{
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include "../../fceu.h"
|
||||
#include "../../utils/md5.h"
|
||||
#include "../../utils/memory.h"
|
||||
|
||||
#include <string>
|
||||
#include "../common/configSys.h"
|
||||
|
@ -173,7 +174,7 @@ FCEUD_NetworkConnect(void)
|
|||
uint32 sblen;
|
||||
|
||||
sblen = 4 + 16 + 16 + 64 + 1 + username.size();
|
||||
sendbuf = (uint8 *)malloc(sblen);
|
||||
sendbuf = (uint8 *)FCEU_dmalloc(sblen);
|
||||
memset(sendbuf, 0, sblen);
|
||||
|
||||
// XXX soules - should use htons instead of en32() from above!
|
||||
|
@ -218,7 +219,7 @@ FCEUD_NetworkConnect(void)
|
|||
#else
|
||||
send(s_Socket, sendbuf, sblen, 0);
|
||||
#endif
|
||||
free(sendbuf);
|
||||
FCEU_dfree(sendbuf);
|
||||
|
||||
#ifdef WIN32
|
||||
recv(s_Socket, (char*)buf, 1, 0);
|
||||
|
@ -338,8 +339,10 @@ FCEUD_NetworkClose(void)
|
|||
void
|
||||
FCEUD_NetplayText(uint8 *text)
|
||||
{
|
||||
char *tot = (char *)malloc(strlen((const char *)text) + 1);
|
||||
char *tot = (char *)FCEU_dmalloc(strlen((const char *)text) + 1);
|
||||
char *tmp;
|
||||
if (!tot)
|
||||
return;
|
||||
strcpy(tot, (const char *)text);
|
||||
tmp = tot;
|
||||
|
||||
|
@ -350,5 +353,5 @@ FCEUD_NetplayText(uint8 *text)
|
|||
tmp++;
|
||||
}
|
||||
puts(tot);
|
||||
free(tot);
|
||||
FCEU_dfree(tot);
|
||||
}
|
||||
|
|
|
@ -442,7 +442,7 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode)
|
|||
ResetGameLoaded();
|
||||
|
||||
if (!AutosaveStatus)
|
||||
AutosaveStatus = (int*)malloc(sizeof(int)*AutosaveQty);
|
||||
AutosaveStatus = (int*)FCEU_dmalloc(sizeof(int)*AutosaveQty);
|
||||
for (AutosaveIndex=0; AutosaveIndex<AutosaveQty; ++AutosaveIndex)
|
||||
AutosaveStatus[AutosaveIndex] = 0;
|
||||
|
||||
|
|
|
@ -1504,7 +1504,7 @@ static int NewiNES_Init(int num)
|
|||
{
|
||||
CloseHandle(mapVROM);
|
||||
mapVROM = NULL;
|
||||
if((VROM = (uint8 *)malloc(CHRRAMSize)) == NULL) return 0;
|
||||
if((VROM = (uint8 *)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1512,11 +1512,11 @@ static int NewiNES_Init(int num)
|
|||
{
|
||||
CloseHandle(mapVROM);
|
||||
mapVROM = NULL;
|
||||
if((VROM = (uint8 *)malloc(CHRRAMSize)) == NULL) return 0;
|
||||
if((VROM = (uint8 *)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if((VROM = (uint8 *)malloc(CHRRAMSize)) == NULL) return 0;
|
||||
if((VROM = (uint8 *)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
|
||||
#endif
|
||||
UNIFchrrama=VROM;
|
||||
SetupCartCHRMapping(0,VROM,CHRRAMSize,1);
|
||||
|
|
|
@ -2763,7 +2763,7 @@ static int movie_isfromsavestate (lua_State *L) {
|
|||
// Common code by the gui library: make sure the screen array is ready
|
||||
static void gui_prepare() {
|
||||
if (!gui_data)
|
||||
gui_data = (uint8*) malloc(LUA_SCREEN_WIDTH*LUA_SCREEN_HEIGHT*4);
|
||||
gui_data = (uint8*) FCEU_dmalloc(LUA_SCREEN_WIDTH*LUA_SCREEN_HEIGHT*4);
|
||||
if (gui_used != GUI_USED_SINCE_LAST_DISPLAY)
|
||||
memset(gui_data, 0, LUA_SCREEN_WIDTH*LUA_SCREEN_HEIGHT*4);
|
||||
gui_used = GUI_USED_SINCE_LAST_DISPLAY;
|
||||
|
@ -4190,7 +4190,7 @@ static int doPopup(lua_State *L, const char* deftype, const char* deficon) {
|
|||
*colon++ = 0;
|
||||
|
||||
int len = strlen(current);
|
||||
char *filename = (char*)malloc(len + 12); // always give excess
|
||||
char *filename = (char*)FCEU_dmalloc(len + 12); // always give excess
|
||||
snprintf(filename, len+12, "%s/xmessage", current);
|
||||
|
||||
if (access(filename, X_OK) == 0) {
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "cheat.h"
|
||||
#include "input.h"
|
||||
#include "driver.h"
|
||||
#include "utils/memory.h"
|
||||
|
||||
int FCEUnetplay=0;
|
||||
|
||||
|
@ -120,11 +121,11 @@ int FCEUNET_SendFile(uint8 cmd, char *fn)
|
|||
|
||||
fstat(fileno(fp),&sb);
|
||||
len = sb.st_size;
|
||||
buf = (char*)malloc(len); //mbg merge 7/17/06 added cast
|
||||
buf = (char*)FCEU_dmalloc(len); //mbg merge 7/17/06 added cast
|
||||
fread(buf, 1, len, fp);
|
||||
fclose(fp);
|
||||
|
||||
cbuf = (char*)malloc(4 + len + len / 1000 + 12); //mbg merge 7/17/06 added cast
|
||||
cbuf = (char*)FCEU_dmalloc(4 + len + len / 1000 + 12); //mbg merge 7/17/06 added cast
|
||||
FCEU_en32lsb((uint8*)cbuf, len); //mbg merge 7/17/06 added cast
|
||||
compress2((uint8*)cbuf + 4, &clen, (uint8*)buf, len, 7); //mbg merge 7/17/06 added casts
|
||||
free(buf);
|
||||
|
@ -164,9 +165,9 @@ static FILE *FetchFile(uint32 remlen)
|
|||
}
|
||||
|
||||
//printf("Receiving file: %d...\n",clen);
|
||||
if(fp = tmpfile())
|
||||
if((fp = tmpfile()))
|
||||
{
|
||||
cbuf = (char *)malloc(clen); //mbg merge 7/17/06 added cast
|
||||
cbuf = (char *)FCEU_dmalloc(clen); //mbg merge 7/17/06 added cast
|
||||
if(!FCEUD_RecvData(cbuf, clen))
|
||||
{
|
||||
NetError();
|
||||
|
@ -183,7 +184,7 @@ static FILE *FetchFile(uint32 remlen)
|
|||
free(cbuf);
|
||||
return(0);
|
||||
}
|
||||
buf = (char *)malloc(len); //mbg merge 7/17/06 added cast
|
||||
buf = (char *)FCEU_dmalloc(len); //mbg merge 7/17/06 added cast
|
||||
uncompress((uint8*)buf, &len, (uint8*)cbuf + 4, clen - 4); //mbg merge 7/17/06 added casts
|
||||
|
||||
fwrite(buf, 1, len, fp);
|
||||
|
|
|
@ -23,56 +23,66 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../types.h"
|
||||
#include "../fceu.h"
|
||||
#include "memory.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "../types.h"
|
||||
#include "../fceu.h"
|
||||
#include "memory.h"
|
||||
|
||||
///allocates the specified number of bytes. exits process if this fails
|
||||
void *FCEU_gmalloc(uint32 size)
|
||||
{
|
||||
|
||||
void *ret;
|
||||
ret=malloc(size);
|
||||
if(!ret)
|
||||
{
|
||||
FCEU_PrintError("Error allocating memory! Doing a hard exit.");
|
||||
exit(1);
|
||||
}
|
||||
//mbg 6/17/08 - sometimes this memory is used as RAM or somesuch without clearing first.
|
||||
//this yields different behavior in debug and release modes.
|
||||
//specifically, saveram wasnt getting cleared so the games thought their savefiles were initialized
|
||||
//so we are going to clear it here.
|
||||
memset(ret,0,size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *FCEU_gmalloc(uint32 size)
|
||||
{
|
||||
|
||||
void *ret;
|
||||
ret=malloc(size);
|
||||
if(!ret)
|
||||
{
|
||||
FCEU_PrintError("Error allocating memory! Doing a hard exit.");
|
||||
exit(1);
|
||||
}
|
||||
//mbg 6/17/08 - sometimes this memory is used as RAM or somesuch without clearing first.
|
||||
//this yields different behavior in debug and release modes.
|
||||
//specifically, saveram wasnt getting cleared so the games thought their savefiles were initialized
|
||||
//so we are going to clear it here.
|
||||
memset(ret,0,size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
///allocates the specified number of bytes. returns null if this fails
|
||||
void *FCEU_malloc(uint32 size)
|
||||
{
|
||||
void *ret;
|
||||
ret=malloc(size);
|
||||
if(!ret)
|
||||
{
|
||||
FCEU_PrintError("Error allocating memory!");
|
||||
return(0);
|
||||
}
|
||||
//mbg 6/17/08 - sometimes this memory is used as RAM or somesuch without clearing first.
|
||||
//this yields different behavior in debug and release modes.
|
||||
//specifically, saveram wasnt getting cleared so the games thought their savefiles were initialized
|
||||
//so we are going to clear it here.
|
||||
memset(ret,0,size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
///frees memory allocated with FCEU_gmalloc
|
||||
void FCEU_gfree(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
///frees memory allocated with FCEU_malloc
|
||||
void FCEU_free(void *ptr) // Might do something with this and FCEU_malloc later...
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
void *FCEU_malloc(uint32 size)
|
||||
{
|
||||
void *ret;
|
||||
ret=malloc(size);
|
||||
if(!ret)
|
||||
{
|
||||
FCEU_PrintError("Error allocating memory!");
|
||||
return(0);
|
||||
}
|
||||
//mbg 6/17/08 - sometimes this memory is used as RAM or somesuch without clearing first.
|
||||
//this yields different behavior in debug and release modes.
|
||||
//specifically, saveram wasnt getting cleared so the games thought their savefiles were initialized
|
||||
//so we are going to clear it here.
|
||||
memset(ret,0,size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
///frees memory allocated with FCEU_gmalloc
|
||||
void FCEU_gfree(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
///frees memory allocated with FCEU_malloc
|
||||
void FCEU_free(void *ptr) // Might do something with this and FCEU_malloc later...
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void *FCEU_dmalloc(uint32 size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void FCEU_dfree(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
|
|
@ -29,3 +29,8 @@ void *FCEU_gmalloc(uint32 size);
|
|||
void FCEU_gfree(void *ptr);
|
||||
void FCEU_free(void *ptr);
|
||||
void FCEU_memmove(void *d, void *s, uint32 l);
|
||||
|
||||
// wrapper for debugging when its needed, otherwise act like
|
||||
// normal malloc/free
|
||||
void *FCEU_dmalloc(uint32 size);
|
||||
void FCEU_dfree(void *ptr);
|
||||
|
|
|
@ -628,7 +628,7 @@ int SaveSnapshot(void)
|
|||
uint8 *tmp=XBuf+FSettings.FirstSLine*256;
|
||||
uint8 *dest,*mal,*mork;
|
||||
|
||||
if(!(mal=mork=dest=(uint8 *)malloc((totallines<<8)+totallines)))
|
||||
if(!(mal=mork=dest=(uint8 *)FCEU_dmalloc((totallines<<8)+totallines)))
|
||||
goto PNGerr;
|
||||
// mork=dest=XBuf;
|
||||
|
||||
|
@ -723,7 +723,7 @@ int SaveSnapshot(char fileName[512])
|
|||
uint8 *tmp=XBuf+FSettings.FirstSLine*256;
|
||||
uint8 *dest,*mal,*mork;
|
||||
|
||||
if(!(mal=mork=dest=(uint8 *)malloc((totallines<<8)+totallines)))
|
||||
if(!(mal=mork=dest=(uint8 *)FCEU_dmalloc((totallines<<8)+totallines)))
|
||||
goto PNGerr;
|
||||
// mork=dest=XBuf;
|
||||
|
||||
|
@ -780,4 +780,4 @@ void ShowFPS(void)
|
|||
// It's not averaging FPS over exactly 1 second, but it's close enough.
|
||||
boopcount = (boopcount + 1) % booplimit;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue