From 601ec28721b250d74e7fd61300226ff07c8a710b Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sat, 6 Jan 2018 00:35:48 -0600 Subject: [PATCH] remove explicit memcpy and add HEAP_SIZE constant --- include/global.h | 2 ++ src/load_save.c | 8 ++++---- src/main.c | 2 +- src/reset_save_heap.c | 4 +--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/global.h b/include/global.h index b6a496dd16..7943fc569e 100644 --- a/include/global.h +++ b/include/global.h @@ -31,6 +31,8 @@ char* strcpy(char *dst0, const char *src0); #define POKEMON_NAME_LENGTH 10 #define OT_NAME_LENGTH 7 +#define HEAP_SIZE 0x1C000 + extern u8 gStringVar1[]; extern u8 gStringVar2[]; extern u8 gStringVar3[]; diff --git a/src/load_save.c b/src/load_save.c index 734f7398b6..a516c08c21 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -115,12 +115,12 @@ void MoveSaveBlocks_ResetHeap(void) saveBlock2Copy->playerTrainerId[3]); // restore saveblock data since the pointers changed - memcpy(gSaveBlock2Ptr, saveBlock2Copy, sizeof(*gSaveBlock2Ptr)); - memcpy(gSaveBlock1Ptr, saveBlock1Copy, sizeof(*gSaveBlock1Ptr)); - memcpy(gPokemonStoragePtr, pokemonStorageCopy, sizeof(*gPokemonStoragePtr)); + *gSaveBlock2Ptr = *saveBlock2Copy; + *gSaveBlock1Ptr = *saveBlock1Copy; + *gPokemonStoragePtr = *pokemonStorageCopy; // heap was destroyed in the copying process, so reset it - InitHeap(gHeap, 0x1C000); + InitHeap(gHeap, HEAP_SIZE); // restore interrupt functions gMain.hblankCallback = hblankCB; diff --git a/src/main.c b/src/main.c index 07ce07f1c3..18d1abdc2a 100644 --- a/src/main.c +++ b/src/main.c @@ -122,7 +122,7 @@ void AgbMain() ClearDma3Requests(); ResetBgs(); SetDefaultFontsPointer(); - InitHeap(gHeap, 0x1C000); + InitHeap(gHeap, HEAP_SIZE); gSoftResetDisabled = FALSE; diff --git a/src/reset_save_heap.c b/src/reset_save_heap.c index d4dbc5f42b..099edce49a 100644 --- a/src/reset_save_heap.c +++ b/src/reset_save_heap.c @@ -23,10 +23,8 @@ void sub_81700F8(void) ResetSaveCounters(); sub_81534D0(0); if (gSaveFileStatus == 0 || gSaveFileStatus == 2) - { Sav2_ClearSetDefault(); - } SetPokemonCryStereo(gSaveBlock2Ptr->optionsSound); - InitHeap(gHeap, 0x1c000); + InitHeap(gHeap, HEAP_SIZE); SetMainCallback2(sub_8086230); }