This commit is contained in:
twinaphex 2015-07-24 15:34:06 +02:00
parent 14c0eecd97
commit 0d6df3fa1f
6 changed files with 36 additions and 53 deletions

View File

@ -543,61 +543,61 @@ static void CPUCleanUp(void)
{
if(rom)
{
MDFN_free(rom);
free(rom);
rom = NULL;
}
if(vram)
{
MDFN_free(vram);
free(vram);
vram = NULL;
}
if(paletteRAM)
{
MDFN_free(paletteRAM);
free(paletteRAM);
paletteRAM = NULL;
}
if(internalRAM)
{
MDFN_free(internalRAM);
free(internalRAM);
internalRAM = NULL;
}
if(workRAM)
{
MDFN_free(workRAM);
free(workRAM);
workRAM = NULL;
}
if(bios)
{
MDFN_free(bios);
free(bios);
bios = NULL;
}
if(pix)
{
MDFN_free(pix);
free(pix);
pix = NULL;
}
if(oam)
{
MDFN_free(oam);
free(oam);
oam = NULL;
}
if(ioMem)
{
MDFN_free(ioMem);
free(ioMem);
ioMem = NULL;
}
if(systemColorMap)
{
MDFN_free(systemColorMap);
free(systemColorMap);
systemColorMap = NULL;
}
@ -633,7 +633,7 @@ static bool LoadCPalette(const char *syspalname, uint8 **ptr, uint32 num_entries
{
FileStream fp(colormap_fn.c_str(), FileStream::MODE_READ);
if(!(*ptr = (uint8 *)MDFN_malloc(num_entries * 3, _("custom color map"))))
if(!(*ptr = (uint8 *)malloc(num_entries * 3)))
{
MDFN_indent(-1);
return(false);
@ -645,7 +645,7 @@ static bool LoadCPalette(const char *syspalname, uint8 **ptr, uint32 num_entries
{
if(*ptr)
{
MDFN_free(*ptr);
free(*ptr);
*ptr = NULL;
}
@ -657,7 +657,7 @@ static bool LoadCPalette(const char *syspalname, uint8 **ptr, uint32 num_entries
{
if(*ptr)
{
MDFN_free(*ptr);
free(*ptr);
*ptr = NULL;
}
@ -742,14 +742,14 @@ static int Load(const char *name, MDFNFILE *fp)
{
layerSettings = 0xFF00;
if(!(rom = (uint8 *)MDFN_malloc(0x2000000, _("ROM"))))
if(!(rom = (uint8 *)malloc(0x2000000)))
return(0);
memset(rom, 0xFF, 0x2000000);
if(!(workRAM = (uint8 *)MDFN_calloc(1, 0x40000, _("Work RAM"))))
if(!(workRAM = (uint8 *)calloc(1, 0x40000)))
{
MDFN_free(rom);
free(rom);
return(0);
}
@ -792,43 +792,43 @@ static int Load(const char *name, MDFNFILE *fp)
}
}
if(!(bios = (uint8 *)MDFN_calloc(1, 0x4000, _("BIOS ROM"))))
if(!(bios = (uint8 *)calloc(1, 0x4000)))
{
CPUCleanUp();
return 0;
}
if(!(internalRAM = (uint8 *)MDFN_calloc(1, 0x8000, _("Internal RAM"))))
if(!(internalRAM = (uint8 *)calloc(1, 0x8000)))
{
CPUCleanUp();
return 0;
}
if(!(paletteRAM = (uint8 *)MDFN_calloc(1, 0x400, _("Palette RAM"))))
if(!(paletteRAM = (uint8 *)calloc(1, 0x400)))
{
CPUCleanUp();
return 0;
}
if(!(vram = (uint8 *)MDFN_calloc(1, 0x20000, _("VRAM"))))
if(!(vram = (uint8 *)calloc(1, 0x20000)))
{
CPUCleanUp();
return 0;
}
if(!(oam = (uint8 *)MDFN_calloc(1, 0x400, _("OAM"))))
if(!(oam = (uint8 *)calloc(1, 0x400)))
{
CPUCleanUp();
return 0;
}
if(!(ioMem = (uint8 *)MDFN_calloc(1, 0x400, _("IO"))))
if(!(ioMem = (uint8 *)calloc(1, 0x400)))
{
CPUCleanUp();
return 0;
}
if(!(systemColorMap = (SysCM*)MDFN_malloc(sizeof(SysCM), _("GBA Color Map"))))
if(!(systemColorMap = (SysCM*)malloc(sizeof(SysCM))))
{
CPUCleanUp();
return(0);

View File

@ -43,7 +43,7 @@ bool MDFNFILE::MakeMemWrapAndClose(void *fp)
f_size = ::ftell((FILE *)fp);
::fseek((FILE *)fp, 0, SEEK_SET);
if (!(f_data = (uint8*)MDFN_malloc(f_size, _("file read buffer"))))
if (!(f_data = (uint8*)malloc(f_size)))
goto fail;
::fread(f_data, 1, f_size, (FILE *)fp);

View File

@ -62,7 +62,7 @@ int GBA_Flash_StateAction(StateMem *sm, int load, int data_only)
bool GBA_Flash_Init(void)
{
if(!(flashSaveMemory = (uint8 *)MDFN_malloc(0x20000, _("flash memory"))))
if(!(flashSaveMemory = (uint8 *)malloc(0x20000)))
return(0);
memset(flashSaveMemory, 0x00, 0x20000);

View File

@ -22,6 +22,17 @@
#include "Gfx.h"
static INLINE void MDFN_FastU32MemsetM8(uint32_t *array, uint32_t value_32, unsigned int u32len)
{
uint32_t *ai;
for(ai = array; ai < array + u32len; ai += 2)
{
ai[0] = value_32;
ai[1] = value_32;
}
}
namespace MDFN_IEN_GBA
{

View File

@ -1,27 +0,0 @@
#ifndef _MDFN_MEMORY_H
#define _MDFN_MEMORY_H
// These functions can be used from driver code or from internal Mednafen code.
//
#include <stdint.h>
#define MDFN_malloc(size, purpose) malloc(size)
#define MDFN_calloc(nmemb, size, purpose) calloc(nmemb, size)
#define MDFN_realloc(ptr, size, purpose) realloc(ptr, size)
#define MDFN_malloc_real(size, purpose) malloc(size)
#define MDFN_calloc_real(nmemb, size, purpose) calloc(nmemb, size)
#define MDFN_realloc_real(ptr, size, purpose) realloc(ptr, size)
#define MDFN_free(ptr) free(ptr)
static inline void MDFN_FastU32MemsetM8(uint32_t *array, uint32_t value_32, unsigned int u32len)
{
for(uint32_t *ai = array; ai < array + u32len; ai += 2)
{
ai[0] = value_32;
ai[1] = value_32;
}
}
#endif

View File

@ -62,6 +62,5 @@ void MDFN_MidLineUpdate(EmulateSpecStruct *espec, int y);
#include "mednafen-driver.h"
#include "mednafen-endian.h"
#include "mednafen-memory.h"
#endif