From 0d6df3fa1f7fff9d9a35fa6e502d468b5d21c918 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 24 Jul 2015 15:34:06 +0200 Subject: [PATCH] Cleanups --- libretro.cpp | 46 +++++++++++++++++++------------------- mednafen/file.cpp | 2 +- mednafen/gba/flash.cpp | 2 +- mednafen/gba/gfx-draw.h | 11 +++++++++ mednafen/mednafen-memory.h | 27 ---------------------- mednafen/mednafen.h | 1 - 6 files changed, 36 insertions(+), 53 deletions(-) delete mode 100644 mednafen/mednafen-memory.h diff --git a/libretro.cpp b/libretro.cpp index 814a88e..dda5176 100755 --- a/libretro.cpp +++ b/libretro.cpp @@ -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); diff --git a/mednafen/file.cpp b/mednafen/file.cpp index a3248dd..3cd0eeb 100644 --- a/mednafen/file.cpp +++ b/mednafen/file.cpp @@ -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); diff --git a/mednafen/gba/flash.cpp b/mednafen/gba/flash.cpp index cc8dcc4..b827f4b 100644 --- a/mednafen/gba/flash.cpp +++ b/mednafen/gba/flash.cpp @@ -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); diff --git a/mednafen/gba/gfx-draw.h b/mednafen/gba/gfx-draw.h index e0b6350..69c593c 100644 --- a/mednafen/gba/gfx-draw.h +++ b/mednafen/gba/gfx-draw.h @@ -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 { diff --git a/mednafen/mednafen-memory.h b/mednafen/mednafen-memory.h deleted file mode 100644 index a46f3c9..0000000 --- a/mednafen/mednafen-memory.h +++ /dev/null @@ -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 - -#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 diff --git a/mednafen/mednafen.h b/mednafen/mednafen.h index 312cb7b..ddf0861 100644 --- a/mednafen/mednafen.h +++ b/mednafen/mednafen.h @@ -62,6 +62,5 @@ void MDFN_MidLineUpdate(EmulateSpecStruct *espec, int y); #include "mednafen-driver.h" #include "mednafen-endian.h" -#include "mednafen-memory.h" #endif