From 88198e64f4398755d0892b63a4176dfabe6f690e Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 13 Nov 2020 16:28:48 +0200 Subject: [PATCH] Minor bug fixes --- Core/cheats.c | 6 +++--- Core/debugger.c | 2 +- Core/save_state.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Core/cheats.c b/Core/cheats.c index 14875e0..451dddb 100644 --- a/Core/cheats.c +++ b/Core/cheats.c @@ -69,7 +69,7 @@ void GB_add_cheat(GB_gameboy_t *gb, const char *description, uint16_t address, u cheat->enabled = enabled; strncpy(cheat->description, description, sizeof(cheat->description)); cheat->description[sizeof(cheat->description) - 1] = 0; - gb->cheats = realloc(gb->cheats, (++gb->cheat_count) * sizeof(*cheat)); + gb->cheats = realloc(gb->cheats, (++gb->cheat_count) * sizeof(gb->cheats[0])); gb->cheats[gb->cheat_count - 1] = cheat; GB_cheat_hash_t **hash = &gb->cheat_hash[hash_addr(address)]; @@ -100,7 +100,7 @@ void GB_remove_cheat(GB_gameboy_t *gb, const GB_cheat_t *cheat) gb->cheats = NULL; } else { - gb->cheats = realloc(gb->cheats, gb->cheat_count * sizeof(*cheat)); + gb->cheats = realloc(gb->cheats, gb->cheat_count * sizeof(gb->cheats[0])); } break; } @@ -222,7 +222,7 @@ void GB_update_cheat(GB_gameboy_t *gb, const GB_cheat_t *_cheat, const char *des } else { (*hash)->size++; - *hash = malloc(sizeof(GB_cheat_hash_t) + sizeof(cheat) * (*hash)->size); + *hash = realloc(*hash, sizeof(GB_cheat_hash_t) + sizeof(cheat) * (*hash)->size); (*hash)->cheats[(*hash)->size - 1] = cheat; } } diff --git a/Core/debugger.c b/Core/debugger.c index 002d455..c27acd3 100644 --- a/Core/debugger.c +++ b/Core/debugger.c @@ -473,7 +473,7 @@ value_t debugger_evaluate(GB_gameboy_t *gb, const char *string, size_t length, bool *error, uint16_t *watchpoint_address, uint8_t *watchpoint_new_value) { - /* Disable watchpoints while evaulating expressions */ + /* Disable watchpoints while evaluating expressions */ uint16_t n_watchpoints = gb->n_watchpoints; gb->n_watchpoints = 0; diff --git a/Core/save_state.c b/Core/save_state.c index 9ef6ae3..827cf57 100644 --- a/Core/save_state.c +++ b/Core/save_state.c @@ -150,7 +150,7 @@ static bool verify_and_update_state_compatibility(GB_gameboy_t *gb, GB_gameboy_t { if (save->ram_size == 0 && (&save->ram_size)[-1] == gb->ram_size) { /* This is a save state with a bad printer struct from a 32-bit OS */ - memcpy(save->extra_oam + 4, save->extra_oam, (uintptr_t)&save->ram_size - (uintptr_t)&save->extra_oam); + memmove(save->extra_oam + 4, save->extra_oam, (uintptr_t)&save->ram_size - (uintptr_t)&save->extra_oam); } if (save->ram_size == 0) { /* Save doesn't have ram size specified, it's a pre 0.12 save state with potentially