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 HEAP_SIZE 0x1C000
#define malloc Alloc
#define calloc(ct, sz) AllocZeroed((ct) * (sz))
#define free Free

View File

@ -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;

View File

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

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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))
{

View File

@ -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;

View File

@ -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);

View File

@ -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++)