Removed malloc macro

This commit is contained in:
Eduardo Quezada 2022-09-16 20:24:26 -03:00
parent 36494c1c1d
commit 63156b4398
10 changed files with 12 additions and 13 deletions

View File

@ -2,7 +2,6 @@
#define GUARD_ALLOC_H #define GUARD_ALLOC_H
#define HEAP_SIZE 0x1C000 #define HEAP_SIZE 0x1C000
#define malloc Alloc
#define calloc(ct, sz) AllocZeroed((ct) * (sz)) #define calloc(ct, sz) AllocZeroed((ct) * (sz))
#define free Free #define free Free

View File

@ -2060,7 +2060,7 @@ static u8 AddDecorationIconObjectFromIconTable(u16 tilesTag, u16 paletteTag, u8
palette.data = GetDecorationIconPicOrPalette(decor, 1); palette.data = GetDecorationIconPicOrPalette(decor, 1);
palette.tag = paletteTag; palette.tag = paletteTag;
LoadCompressedSpritePalette(&palette); LoadCompressedSpritePalette(&palette);
template = malloc(sizeof(struct SpriteTemplate)); template = Alloc(sizeof(struct SpriteTemplate));
*template = gItemIconSpriteTemplate; *template = gItemIconSpriteTemplate;
template->tileTag = tilesTag; template->tileTag = tilesTag;
template->paletteTag = paletteTag; template->paletteTag = paletteTag;

View File

@ -73,7 +73,7 @@ void CB2_ShowDiploma(void)
ResetPaletteFade(); ResetPaletteFade();
FreeAllSpritePalettes(); FreeAllSpritePalettes();
LoadPalette(sDiplomaPalettes, 0, 64); LoadPalette(sDiplomaPalettes, 0, 64);
sDiplomaTilemapPtr = malloc(0x1000); sDiplomaTilemapPtr = Alloc(0x1000);
InitDiplomaBg(); InitDiplomaBg();
InitDiplomaWindow(); InitDiplomaWindow();
ResetTempTileDataBuffers(); ResetTempTileDataBuffers();

View File

@ -1627,7 +1627,7 @@ static bool8 InitEasyChatScreenStruct(u8 type, u16 *words, u8 displayedPersonTyp
u8 templateId; u8 templateId;
int i; int i;
sEasyChatScreen = malloc(sizeof(*sEasyChatScreen)); sEasyChatScreen = Alloc(sizeof(*sEasyChatScreen));
if (sEasyChatScreen == NULL) if (sEasyChatScreen == NULL)
return FALSE; return FALSE;

View File

@ -1537,7 +1537,7 @@ u8 CreateObjectGraphicsSprite(u16 graphicsId, void (*callback)(struct Sprite *),
struct Sprite *sprite; struct Sprite *sprite;
u8 spriteId; u8 spriteId;
spriteTemplate = malloc(sizeof(struct SpriteTemplate)); spriteTemplate = Alloc(sizeof(struct SpriteTemplate));
CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, callback, spriteTemplate, &subspriteTables); CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, callback, spriteTemplate, &subspriteTables);
if (spriteTemplate->paletteTag != TAG_NONE) if (spriteTemplate->paletteTag != TAG_NONE)
LoadObjectEventPalette(spriteTemplate->paletteTag); LoadObjectEventPalette(spriteTemplate->paletteTag);

View File

@ -92,7 +92,7 @@ static const struct WindowTemplate sFieldRegionMapWindowTemplates[] =
void FieldInitRegionMap(MainCallback callback) void FieldInitRegionMap(MainCallback callback)
{ {
SetVBlankCallback(NULL); SetVBlankCallback(NULL);
sFieldRegionMapHandler = malloc(sizeof(*sFieldRegionMapHandler)); sFieldRegionMapHandler = Alloc(sizeof(*sFieldRegionMapHandler));
sFieldRegionMapHandler->state = 0; sFieldRegionMapHandler->state = 0;
sFieldRegionMapHandler->callback = callback; sFieldRegionMapHandler->callback = callback;
SetMainCallback2(MCB2_InitRegionMapRegisters); SetMainCallback2(MCB2_InitRegionMapRegisters);

View File

@ -1608,7 +1608,7 @@ void CB2_LinkError(void)
SetVBlankCallback(VBlankCB_LinkError); SetVBlankCallback(VBlankCB_LinkError);
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sLinkErrorBgTemplates, ARRAY_COUNT(sLinkErrorBgTemplates)); InitBgsFromTemplates(0, sLinkErrorBgTemplates, ARRAY_COUNT(sLinkErrorBgTemplates));
sLinkErrorBgTilemapBuffer = tilemapBuffer = malloc(BG_SCREEN_SIZE); sLinkErrorBgTilemapBuffer = tilemapBuffer = Alloc(BG_SCREEN_SIZE);
SetBgTilemapBuffer(1, tilemapBuffer); SetBgTilemapBuffer(1, tilemapBuffer);
if (InitWindows(sLinkErrorWindowTemplates)) if (InitWindows(sLinkErrorWindowTemplates))
{ {

View File

@ -315,8 +315,8 @@ static void Task_RecordMixing_Main(u8 taskId)
switch (tState) switch (tState)
{ {
case 0: // init case 0: // init
sSentRecord = malloc(sizeof(*sSentRecord)); sSentRecord = Alloc(sizeof(*sSentRecord));
sReceivedRecords = malloc(sizeof(*sReceivedRecords) * MAX_LINK_PLAYERS); sReceivedRecords = Alloc(sizeof(*sReceivedRecords) * MAX_LINK_PLAYERS);
SetLocalLinkPlayerId(gSpecialVar_0x8005); SetLocalLinkPlayerId(gSpecialVar_0x8005);
VarSet(VAR_TEMP_0, 1); VarSet(VAR_TEMP_0, 1);
sReadyToReceive = FALSE; sReadyToReceive = FALSE;
@ -689,7 +689,7 @@ static void ReceiveLilycoveLadyData(LilycoveLady *records, size_t recordSize, u8
if (GetLilycoveLadyId() == 0) if (GetLilycoveLadyId() == 0)
{ {
lilycoveLady = malloc(sizeof(*lilycoveLady)); lilycoveLady = Alloc(sizeof(*lilycoveLady));
if (lilycoveLady == NULL) if (lilycoveLady == NULL)
return; return;

View File

@ -1664,7 +1664,7 @@ void CB2_OpenFlyMap(void)
SetGpuReg(REG_OFFSET_BG2HOFS, 0); SetGpuReg(REG_OFFSET_BG2HOFS, 0);
SetGpuReg(REG_OFFSET_BG3HOFS, 0); SetGpuReg(REG_OFFSET_BG3HOFS, 0);
SetGpuReg(REG_OFFSET_BG3VOFS, 0); SetGpuReg(REG_OFFSET_BG3VOFS, 0);
sFlyMap = malloc(sizeof(*sFlyMap)); sFlyMap = Alloc(sizeof(*sFlyMap));
if (sFlyMap == NULL) if (sFlyMap == NULL)
{ {
SetMainCallback2(CB2_ReturnToFieldWithOpenMenu); SetMainCallback2(CB2_ReturnToFieldWithOpenMenu);

View File

@ -3450,7 +3450,7 @@ void ReceiveTvShowsData(void *src, u32 size, u8 playersLinkId)
TVShow (*rmBuffer2)[MAX_LINK_PLAYERS][TV_SHOWS_COUNT]; TVShow (*rmBuffer2)[MAX_LINK_PLAYERS][TV_SHOWS_COUNT];
TVShow (*rmBuffer)[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) if (rmBuffer2 != NULL)
{ {
for (i = 0; i < MAX_LINK_PLAYERS; i++) 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 (*rmBuffer2)[MAX_LINK_PLAYERS][POKE_NEWS_COUNT];
PokeNews (*rmBuffer)[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) if (rmBuffer2 != NULL)
{ {
for (i = 0; i < MAX_LINK_PLAYERS; i++) for (i = 0; i < MAX_LINK_PLAYERS; i++)