From 63156b4398213bc89fb6666f2126f751902a4d84 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 16 Sep 2022 20:24:26 -0300 Subject: [PATCH] Removed malloc macro --- gflib/malloc.h | 1 - src/decoration.c | 2 +- src/diploma.c | 2 +- src/easy_chat.c | 2 +- src/event_object_movement.c | 2 +- src/field_region_map.c | 2 +- src/link.c | 2 +- src/record_mixing.c | 6 +++--- src/region_map.c | 2 +- src/tv.c | 4 ++-- 10 files changed, 12 insertions(+), 13 deletions(-) diff --git a/gflib/malloc.h b/gflib/malloc.h index 8d49e0be7..27004adf7 100644 --- a/gflib/malloc.h +++ b/gflib/malloc.h @@ -2,7 +2,6 @@ #define GUARD_ALLOC_H #define HEAP_SIZE 0x1C000 -#define malloc Alloc #define calloc(ct, sz) AllocZeroed((ct) * (sz)) #define free Free diff --git a/src/decoration.c b/src/decoration.c index c5c7c02c3..2384daa80 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -2060,7 +2060,7 @@ static u8 AddDecorationIconObjectFromIconTable(u16 tilesTag, u16 paletteTag, u8 palette.data = GetDecorationIconPicOrPalette(decor, 1); palette.tag = paletteTag; LoadCompressedSpritePalette(&palette); - template = malloc(sizeof(struct SpriteTemplate)); + template = Alloc(sizeof(struct SpriteTemplate)); *template = gItemIconSpriteTemplate; template->tileTag = tilesTag; template->paletteTag = paletteTag; diff --git a/src/diploma.c b/src/diploma.c index ce31578dc..a30d71554 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -73,7 +73,7 @@ void CB2_ShowDiploma(void) ResetPaletteFade(); FreeAllSpritePalettes(); LoadPalette(sDiplomaPalettes, 0, 64); - sDiplomaTilemapPtr = malloc(0x1000); + sDiplomaTilemapPtr = Alloc(0x1000); InitDiplomaBg(); InitDiplomaWindow(); ResetTempTileDataBuffers(); diff --git a/src/easy_chat.c b/src/easy_chat.c index ebc843b3c..054c65c0f 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -1627,7 +1627,7 @@ static bool8 InitEasyChatScreenStruct(u8 type, u16 *words, u8 displayedPersonTyp u8 templateId; int i; - sEasyChatScreen = malloc(sizeof(*sEasyChatScreen)); + sEasyChatScreen = Alloc(sizeof(*sEasyChatScreen)); if (sEasyChatScreen == NULL) return FALSE; diff --git a/src/event_object_movement.c b/src/event_object_movement.c index a63eeb22b..83f12c4bb 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1537,7 +1537,7 @@ u8 CreateObjectGraphicsSprite(u16 graphicsId, void (*callback)(struct Sprite *), struct Sprite *sprite; u8 spriteId; - spriteTemplate = malloc(sizeof(struct SpriteTemplate)); + spriteTemplate = Alloc(sizeof(struct SpriteTemplate)); CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, callback, spriteTemplate, &subspriteTables); if (spriteTemplate->paletteTag != TAG_NONE) LoadObjectEventPalette(spriteTemplate->paletteTag); diff --git a/src/field_region_map.c b/src/field_region_map.c index 5e14920fb..43055174f 100644 --- a/src/field_region_map.c +++ b/src/field_region_map.c @@ -92,7 +92,7 @@ static const struct WindowTemplate sFieldRegionMapWindowTemplates[] = void FieldInitRegionMap(MainCallback callback) { SetVBlankCallback(NULL); - sFieldRegionMapHandler = malloc(sizeof(*sFieldRegionMapHandler)); + sFieldRegionMapHandler = Alloc(sizeof(*sFieldRegionMapHandler)); sFieldRegionMapHandler->state = 0; sFieldRegionMapHandler->callback = callback; SetMainCallback2(MCB2_InitRegionMapRegisters); diff --git a/src/link.c b/src/link.c index 57e33c811..b01be9d89 100644 --- a/src/link.c +++ b/src/link.c @@ -1608,7 +1608,7 @@ void CB2_LinkError(void) SetVBlankCallback(VBlankCB_LinkError); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sLinkErrorBgTemplates, ARRAY_COUNT(sLinkErrorBgTemplates)); - sLinkErrorBgTilemapBuffer = tilemapBuffer = malloc(BG_SCREEN_SIZE); + sLinkErrorBgTilemapBuffer = tilemapBuffer = Alloc(BG_SCREEN_SIZE); SetBgTilemapBuffer(1, tilemapBuffer); if (InitWindows(sLinkErrorWindowTemplates)) { diff --git a/src/record_mixing.c b/src/record_mixing.c index c899db25e..72edd52f2 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -315,8 +315,8 @@ static void Task_RecordMixing_Main(u8 taskId) switch (tState) { case 0: // init - sSentRecord = malloc(sizeof(*sSentRecord)); - sReceivedRecords = malloc(sizeof(*sReceivedRecords) * MAX_LINK_PLAYERS); + sSentRecord = Alloc(sizeof(*sSentRecord)); + sReceivedRecords = Alloc(sizeof(*sReceivedRecords) * MAX_LINK_PLAYERS); SetLocalLinkPlayerId(gSpecialVar_0x8005); VarSet(VAR_TEMP_0, 1); sReadyToReceive = FALSE; @@ -689,7 +689,7 @@ static void ReceiveLilycoveLadyData(LilycoveLady *records, size_t recordSize, u8 if (GetLilycoveLadyId() == 0) { - lilycoveLady = malloc(sizeof(*lilycoveLady)); + lilycoveLady = Alloc(sizeof(*lilycoveLady)); if (lilycoveLady == NULL) return; diff --git a/src/region_map.c b/src/region_map.c index a4db1cb04..8157f8a4e 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1664,7 +1664,7 @@ void CB2_OpenFlyMap(void) SetGpuReg(REG_OFFSET_BG2HOFS, 0); SetGpuReg(REG_OFFSET_BG3HOFS, 0); SetGpuReg(REG_OFFSET_BG3VOFS, 0); - sFlyMap = malloc(sizeof(*sFlyMap)); + sFlyMap = Alloc(sizeof(*sFlyMap)); if (sFlyMap == NULL) { SetMainCallback2(CB2_ReturnToFieldWithOpenMenu); diff --git a/src/tv.c b/src/tv.c index 0c394acf7..fe663bb35 100644 --- a/src/tv.c +++ b/src/tv.c @@ -3450,7 +3450,7 @@ void ReceiveTvShowsData(void *src, u32 size, u8 playersLinkId) TVShow (*rmBuffer2)[MAX_LINK_PLAYERS][TV_SHOWS_COUNT]; TVShow (*rmBuffer)[MAX_LINK_PLAYERS][TV_SHOWS_COUNT]; - rmBuffer2 = malloc(MAX_LINK_PLAYERS * TV_SHOWS_COUNT * sizeof(TVShow)); + rmBuffer2 = Alloc(MAX_LINK_PLAYERS * TV_SHOWS_COUNT * sizeof(TVShow)); if (rmBuffer2 != NULL) { for (i = 0; i < MAX_LINK_PLAYERS; i++) @@ -3835,7 +3835,7 @@ void ReceivePokeNewsData(void *src, u32 size, u8 playersLinkId) PokeNews (*rmBuffer2)[MAX_LINK_PLAYERS][POKE_NEWS_COUNT]; PokeNews (*rmBuffer)[MAX_LINK_PLAYERS][POKE_NEWS_COUNT]; - rmBuffer2 = malloc(MAX_LINK_PLAYERS * POKE_NEWS_COUNT * sizeof(PokeNews)); + rmBuffer2 = Alloc(MAX_LINK_PLAYERS * POKE_NEWS_COUNT * sizeof(PokeNews)); if (rmBuffer2 != NULL) { for (i = 0; i < MAX_LINK_PLAYERS; i++)