all repos — mgba @ 11dc9f516112f2915957328bda860d24bde6acb2

mGBA Game Boy Advance Emulator

Libretro: Use anonymous memory mappers for large blocks of memor
Jeffrey Pfau jeffrey@endrift.com
Mon, 07 Sep 2015 22:21:25 -0700
commit

11dc9f516112f2915957328bda860d24bde6acb2

parent

31686c374ed78d8f15190c814276ed555fb0949a

2 files changed, 9 insertions(+), 5 deletions(-)

jump to
M CHANGESCHANGES

@@ -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.csrc/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); }