all repos — mgba @ 589b5f473c86c3874d858817f19c2d89f8359996

mGBA Game Boy Advance Emulator

Libretro: Copy game data; apparently it is freed by the frontend before starting the game
Jeffrey Pfau jeffrey@endrift.com
Mon, 09 Mar 2015 22:07:50 -0700
commit

589b5f473c86c3874d858817f19c2d89f8359996

parent

207219b25e8a770e2cb58d72ceefee4f9b388245

1 files changed, 7 insertions(+), 1 deletions(-)

jump to
M src/platform/libretro/libretro.csrc/platform/libretro/libretro.c

@@ -28,6 +28,7 @@ static struct GBA gba;

static struct ARMCore cpu; static struct GBAVideoSoftwareRenderer renderer; static struct VFile* rom; +static void* data; static struct VFile* save; static void* savedata; static struct GBAAVStream stream;

@@ -168,8 +169,11 @@ }

bool retro_load_game(const struct retro_game_info* game) { if (game->data) { - rom = VFileFromMemory((void*) game->data, game->size); // TODO: readonly VFileMem + data = malloc(game->size); + memcpy(data, game->data, game->size); + rom = VFileFromMemory(data, game->size); } else { + data = 0; rom = VFileOpen(game->path, O_RDONLY); } if (!rom) {

@@ -198,6 +202,8 @@

void retro_unload_game(void) { rom->close(rom); rom = 0; + free(data); + data = 0; save->close(save); save = 0; free(savedata);