Libretro: Use anonymous memory mappers for large blocks of memor
Jeffrey Pfau jeffrey@endrift.com
Mon, 07 Sep 2015 22:21:25 -0700
2 files changed,
9 insertions(+),
5 deletions(-)
M
CHANGES
→
CHANGES
@@ -19,6 +19,7 @@ - GBA: Attempting to save a screenshot-style savestate should be allowed without libpng
- GBA: Better memory handling with PNG savestates - GBA Audio: Allow GBAAVStream to have no video callback - ARM7: Force disable LTO on two files to work around a GCC bug + - Libretro: Use anonymous memory mappers for large blocks of memory 0.3.0: (2015-08-16) Features:
M
src/platform/libretro/libretro.c
→
src/platform/libretro/libretro.c
@@ -11,6 +11,7 @@ #include "gba/renderers/video-software.h"
#include "gba/serialize.h" #include "gba/context/context.h" #include "util/circle-buffer.h" +#include "util/memory.h" #include "util/vfs.h" #define SAMPLES 1024@@ -37,6 +38,7 @@
static struct GBAContext context; static struct GBAVideoSoftwareRenderer renderer; static void* data; +static size_t dataSize; static void* savedata; static struct GBAAVStream stream; static int rumbleLevel;@@ -246,7 +248,8 @@
bool retro_load_game(const struct retro_game_info* game) { struct VFile* rom; if (game->data) { - data = malloc(game->size); + data = anonymousMemoryMap(game->size); + dataSize = game->size; memcpy(data, game->data, game->size); rom = VFileFromMemory(data, game->size); } else {@@ -258,11 +261,11 @@ return false;
} if (!GBAIsROM(rom)) { rom->close(rom); - free(data); + mappedMemoryFree(data, game->size); return false; } - savedata = malloc(SIZE_CART_FLASH1M); + savedata = anonymousMemoryMap(SIZE_CART_FLASH1M); struct VFile* save = VFileFromMemory(savedata, SIZE_CART_FLASH1M); GBAContextLoadROMFromVFile(&context, rom, save);@@ -272,9 +275,9 @@ }
void retro_unload_game(void) { GBAContextStop(&context); - free(data); + mappedMemoryFree(data, dataSize); data = 0; - free(savedata); + mappedMemoryFree(savedata, SIZE_CART_FLASH1M); savedata = 0; CircleBufferDeinit(&rumbleHistory); }