Skip to content

Commit

Permalink
"Fix" memory leak in hireso
Browse files Browse the repository at this point in the history
  • Loading branch information
louist103 committed May 12, 2024
1 parent 844af40 commit 80fa5e2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions mm/src/code/z_play_hireso.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,13 +1115,15 @@ void BombersNotebook_Draw(BombersNotebook* this, GraphicsContext* gfxCtx) {
void BombersNotebook_LoadFiles(BombersNotebook* this, s32 flag) {
switch (this->loadState) {
case BOMBERS_NOTEBOOK_LOAD_STATE_NONE:
#if 0
if (this->scheduleDmaSegment == NULL) {
break;
}
CmpDma_LoadAllFiles(this->scheduleDmaSegmentStart, this->scheduleDmaSegment, this->scheduleDmaSegmentSize);
osCreateMesgQueue(&this->loadQueue, this->loadMsg, ARRAY_COUNT(this->loadMsg));
DmaMgr_SendRequestImpl(&this->dmaRequest, this->scheduleSegment, this->scheduleSegmentStart,
this->scheduleSegmentSize, 0, &this->loadQueue, OS_MESG_PTR(NULL));
#endif
this->loadState = BOMBERS_NOTEBOOK_LOAD_STATE_STARTED;
// fallthrough
case BOMBERS_NOTEBOOK_LOAD_STATE_STARTED:
Expand Down Expand Up @@ -1155,7 +1157,8 @@ void BombersNotebook_Update(PlayState* play, BombersNotebook* this, Input* input
s32 stickAdjY = input->rel.stick_y;
s32 cursorEntryScan;


// #region 2S2H [Port] We don't need to malloc these with our asset setup
#if 0
this->scheduleDmaSegmentStart = SEGMENT_ROM_START(schedule_dma_static_yar);
this->scheduleDmaSegmentSize = SEGMENT_ROM_SIZE(schedule_dma_static_syms);
this->scheduleSegmentStart = SEGMENT_ROM_START(schedule_static);
Expand All @@ -1168,7 +1171,7 @@ void BombersNotebook_Update(PlayState* play, BombersNotebook* this, Input* input
if (this->scheduleSegment == NULL) {
this->scheduleSegment = ZeldaArena_Malloc(this->scheduleSegmentSize);
}

#endif
BombersNotebook_LoadFiles(this, OS_MESG_NOBLOCK);

if (this->loadState == BOMBERS_NOTEBOOK_LOAD_STATE_DONE) {
Expand Down Expand Up @@ -1348,9 +1351,17 @@ void BombersNotebook_Destroy(BombersNotebook* this) {
if (this->loadState == BOMBERS_NOTEBOOK_LOAD_STATE_STARTED) {
BombersNotebook_LoadFiles(this, OS_MESG_BLOCK);
}
#if 0
if (this->scheduleDmaSegment != NULL) {
ZeldaArena_Free(this->scheduleDmaSegment);
this->scheduleDmaSegment = NULL;
}

if (this->scheduleSegment != NULL) {
ZeldaArena_Free(this->scheduleSegment);
this->scheduleSegment = NULL;
}
#endif
//! @bug: Does not free malloc'd memory for schedule segment
// #region 2S2H [Port] fix the bug by removing the mallocs since they aren't needed for out setup.
}

0 comments on commit 80fa5e2

Please sign in to comment.