From e412ec30a0d9ddcf1a1cc427488fdc8279ae08a6 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 16 Sep 2022 20:34:22 -0300 Subject: [PATCH] Removed calloc macro --- gflib/malloc.h | 1 - src/frontier_util.c | 6 +++--- src/link_rfu_3.c | 2 +- src/mail.c | 2 +- src/secret_base.c | 2 +- src/tv.c | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gflib/malloc.h b/gflib/malloc.h index 27004adf7..e21bd5a2c 100644 --- a/gflib/malloc.h +++ b/gflib/malloc.h @@ -2,7 +2,6 @@ #define GUARD_ALLOC_H #define HEAP_SIZE 0x1C000 -#define calloc(ct, sz) AllocZeroed((ct) * (sz)) #define free Free #define FREE_AND_SET_NULL(ptr) \ diff --git a/src/frontier_util.c b/src/frontier_util.c index f5dde452f..7906df736 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -2271,7 +2271,7 @@ static void Fill1PRecords(struct RankingHall1P *dst, s32 hallFacilityId, s32 lvl { s32 i, j; struct RankingHall1P record1P[HALL_RECORDS_COUNT + 1]; - struct PlayerHallRecords *playerHallRecords = calloc(1, sizeof(struct PlayerHallRecords)); + struct PlayerHallRecords *playerHallRecords = AllocZeroed(sizeof(struct PlayerHallRecords)); GetPlayerHallRecords(playerHallRecords); for (i = 0; i < HALL_RECORDS_COUNT; i++) @@ -2305,7 +2305,7 @@ static void Fill2PRecords(struct RankingHall2P *dst, s32 lvlMode) { s32 i, j; struct RankingHall2P record2P[HALL_RECORDS_COUNT + 1]; - struct PlayerHallRecords *playerHallRecords = calloc(1, sizeof(struct PlayerHallRecords)); + struct PlayerHallRecords *playerHallRecords = AllocZeroed(sizeof(struct PlayerHallRecords)); GetPlayerHallRecords(playerHallRecords); for (i = 0; i < HALL_RECORDS_COUNT; i++) @@ -2421,7 +2421,7 @@ void ClearRankingHallRecords(void) void SaveGameFrontier(void) { s32 i; - struct Pokemon *monsParty = calloc(PARTY_SIZE, sizeof(struct Pokemon)); + struct Pokemon *monsParty = AllocZeroed(sizeof(struct Pokemon) * PARTY_SIZE); for (i = 0; i < PARTY_SIZE; i++) monsParty[i] = gPlayerParty[i]; diff --git a/src/link_rfu_3.c b/src/link_rfu_3.c index 0825daea2..26102a8c3 100644 --- a/src/link_rfu_3.c +++ b/src/link_rfu_3.c @@ -913,7 +913,7 @@ void SaveLinkTrainerNames(void) s32 j; s32 nextSpace; s32 connectedTrainerRecordIndices[MAX_RFU_PLAYERS]; - struct TrainerNameRecord *newRecords = calloc(ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords), sizeof(struct TrainerNameRecord)); + struct TrainerNameRecord *newRecords = AllocZeroed(sizeof(gSaveBlock1Ptr->trainerNameRecords)); // Check if we already have a record saved for connected trainers. for (i = 0; i < GetLinkPlayerCount(); i++) diff --git a/src/mail.c b/src/mail.c index 651fcbb84..f1e4fbedf 100644 --- a/src/mail.c +++ b/src/mail.c @@ -448,7 +448,7 @@ void ReadMail(struct Mail *mail, void (*exitCallback)(void), bool8 hasText) u16 buffer[2]; u16 species; - sMailRead = calloc(1, sizeof(*sMailRead)); + sMailRead = AllocZeroed(sizeof(*sMailRead)); sMailRead->language = GAME_LANGUAGE; sMailRead->international = TRUE; sMailRead->parserSingle = CopyEasyChatWord; diff --git a/src/secret_base.c b/src/secret_base.c index 74129d3ff..7459ba66b 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -921,7 +921,7 @@ static void Task_ShowSecretBaseRegistryMenu(u8 taskId) tSelectedRow = 0; tScrollOffset = 0; ClearDialogWindowAndFrame(0, FALSE); - sRegistryMenu = calloc(1, sizeof(*sRegistryMenu)); + sRegistryMenu = AllocZeroed(sizeof(*sRegistryMenu)); tMainWindowId = AddWindow(&sRegistryWindowTemplates[0]); BuildRegistryMenuItems(taskId); FinalizeRegistryMenu(taskId); diff --git a/src/tv.c b/src/tv.c index fe663bb35..530dd5d94 100644 --- a/src/tv.c +++ b/src/tv.c @@ -3966,7 +3966,7 @@ static void TranslateShowNames(TVShow *show, u32 language) int i; TVShow **shows; - shows = calloc(11, sizeof(TVShow *)); + shows = AllocZeroed(sizeof(TVShow *) * 11); for (i = 0; i < LAST_TVSHOW_IDX; i++) { switch (show[i].common.kind)