Skip to content

Commit 0d85caa

Browse files
committed
GameState_, GameAlloc_, SystemArena_ & ZeldaArena_
1 parent 4606929 commit 0d85caa

38 files changed

+132
-133
lines changed

soh/include/functions.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -987,13 +987,13 @@ void Lights_GlowCheck(GlobalContext* globalCtx);
987987
void Lights_DrawGlow(GlobalContext* globalCtx);
988988
void ZeldaArena_CheckPointer(void* ptr, size_t size, const char* name, const char* action);
989989
void* ZeldaArena_Malloc(size_t size);
990-
void* ZeldaArena_MallocDebug(size_t size, const char* file, s32 line);
990+
void* ZeldaArena_MallocDebug(size_t size);
991991
void* ZeldaArena_MallocR(size_t size);
992-
void* ZeldaArena_MallocRDebug(size_t size, const char* file, s32 line);
992+
void* ZeldaArena_MallocRDebug(size_t size);
993993
void* ZeldaArena_Realloc(void* ptr, size_t newSize);
994-
void* ZeldaArena_ReallocDebug(void* ptr, size_t newSize, const char* file, s32 line);
994+
void* ZeldaArena_ReallocDebug(void* ptr, size_t newSize);
995995
void ZeldaArena_Free(void* ptr);
996-
void ZeldaArena_FreeDebug(void* ptr, const char* file, s32 line);
996+
void ZeldaArena_FreeDebug(void* ptr);
997997
void* ZeldaArena_Calloc(size_t num, size_t size);
998998
void ZeldaArena_Display();
999999
void ZeldaArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc);
@@ -1600,9 +1600,9 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
16001600
void GameState_Destroy(GameState* gameState);
16011601
GameStateFunc GameState_GetInit(GameState* gameState);
16021602
u32 GameState_IsRunning(GameState* gameState);
1603-
void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line);
1603+
void* GameState_Alloc(GameState* gameState, size_t size);
16041604
void func_800C55D0(GameAlloc* this);
1605-
void* GameAlloc_MallocDebug(GameAlloc* this, size_t size, const char* file, s32 line);
1605+
void* GameAlloc_MallocDebug(GameAlloc* this, size_t size);
16061606
void* GameAlloc_Malloc(GameAlloc* this, size_t size);
16071607
void GameAlloc_Free(GameAlloc* this, void* data);
16081608
void GameAlloc_Cleanup(GameAlloc* this);
@@ -2175,13 +2175,13 @@ f32 roundf(f32 x);
21752175
f32 nearbyintf(f32 x);*/
21762176
void SystemArena_CheckPointer(void* ptr, size_t size, const char* name, const char* action);
21772177
void* SystemArena_Malloc(size_t size);
2178-
void* SystemArena_MallocDebug(size_t size, const char* file, s32 line);
2178+
void* SystemArena_MallocDebug(size_t size);
21792179
void* SystemArena_MallocR(size_t size);
2180-
void* SystemArena_MallocRDebug(size_t size, const char* file, s32 line);
2180+
void* SystemArena_MallocRDebug(size_t size);
21812181
void* SystemArena_Realloc(void* ptr, size_t newSize);
2182-
void* SystemArena_ReallocDebug(void* ptr, size_t newSize, const char* file, s32 line);
2182+
void* SystemArena_ReallocDebug(void* ptr, size_t newSize);
21832183
void SystemArena_Free(void* ptr);
2184-
void SystemArena_FreeDebug(void* ptr, const char* file, s32 line);
2184+
void SystemArena_FreeDebug(void* ptr);
21852185
void* SystemArena_Calloc(size_t num, size_t size);
21862186
void SystemArena_Display(void);
21872187
void SystemArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc);

soh/include/macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
#define LOG_FLOAT(exp, value) ((void)0)
112112
#endif
113113

114-
// LogUtils as macro
114+
// LogUtils
115115
#ifndef NDEBUG
116116
#define LOG_POINTER(val, max, ptr, name) LogUtils_LogPointer(val, max, ptr, name, __FILE__, __LINE__)
117117
#define LOG_CHECK_BOUNDARY(name, value, unk) LogUtils_CheckBoundary(name, value, unk, __FILE__, __LINE__)

soh/src/code/game.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ void GameState_InitArena(GameState* gameState, size_t size) {
431431
void* arena;
432432

433433
osSyncPrintf("ハイラル確保 サイズ=%u バイト\n"); // "Hyrule reserved size = %u bytes"
434-
arena = GameAlloc_MallocDebug(&gameState->alloc, size, __FILE__, __LINE__);
434+
arena = GameAlloc_MallocDebug(&gameState->alloc, size);
435435
if (arena != NULL) {
436436
THA_Ct(&gameState->tha, arena, size);
437437
osSyncPrintf("ハイラル確保成功\n"); // "Successful Hyral"
@@ -466,7 +466,7 @@ void GameState_Realloc(GameState* gameState, size_t size) {
466466
}
467467

468468
osSyncPrintf("ハイラル再確保 サイズ=%u バイト\n", size); // "Hyral reallocate size = %u bytes"
469-
gameArena = GameAlloc_MallocDebug(alloc, size, __FILE__, __LINE__);
469+
gameArena = GameAlloc_MallocDebug(alloc, size);
470470
if (gameArena != NULL) {
471471
THA_Ct(&gameState->tha, gameArena, size);
472472
osSyncPrintf("ハイラル再確保成功\n"); // "Successful reacquisition of Hyrule"
@@ -569,7 +569,7 @@ u32 GameState_IsRunning(GameState* gameState) {
569569
return gameState->running;
570570
}
571571

572-
void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line)
572+
void* GameState_Alloc(GameState* gameState, size_t size)
573573
{
574574
void* ret;
575575

@@ -590,7 +590,7 @@ void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line)
590590
}
591591
if (ret != NULL) {
592592
osSyncPrintf(VT_FGCOL(GREEN));
593-
osSyncPrintf("game_alloc(%08x) %08x-%08x [%s:%d]\n", size, ret, (uintptr_t)ret + size, file, line);
593+
osSyncPrintf("game_alloc(%08x) %08x-%08x [%s:%d]\n", size, ret, (uintptr_t)ret + size, __FILE__, __LINE__);
594594
osSyncPrintf(VT_RST);
595595
}
596596
return ret;

soh/src/code/gamealloc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ void GameAlloc_Log(GameAlloc* this) {
1212
}
1313
}
1414

15-
void* GameAlloc_MallocDebug(GameAlloc* this, size_t size, const char* file, s32 line) {
16-
GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), file, line);
15+
void* GameAlloc_MallocDebug(GameAlloc* this, size_t size) {
16+
GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry));
1717

1818
if (ptr != NULL) {
1919
ptr->size = size;
@@ -29,7 +29,7 @@ void* GameAlloc_MallocDebug(GameAlloc* this, size_t size, const char* file, s32
2929
}
3030

3131
void* GameAlloc_Malloc(GameAlloc* this, size_t size) {
32-
GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), __FILE__, __LINE__);
32+
GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry));
3333

3434
if (ptr != NULL) {
3535
ptr->size = size;
@@ -54,7 +54,7 @@ void GameAlloc_Free(GameAlloc* this, void* data) {
5454
ptr->prev->next = ptr->next;
5555
ptr->next->prev = ptr->prev;
5656
this->head = this->base.prev;
57-
SystemArena_FreeDebug(ptr, __FILE__, __LINE__);
57+
SystemArena_FreeDebug(ptr);
5858
}
5959
}
6060

@@ -65,7 +65,7 @@ void GameAlloc_Cleanup(GameAlloc* this) {
6565
while (&this->base != next) {
6666
cur = next;
6767
next = next->next;
68-
SystemArena_FreeDebug(cur, __FILE__, __LINE__);
68+
SystemArena_FreeDebug(cur);
6969
}
7070

7171
this->head = &this->base;

soh/src/code/graph.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static void RunFrame()
454454
size = runFrameContext.ovl->instanceSize;
455455
osSyncPrintf("クラスサイズ=%dバイト\n", size); // "Class size = %d bytes"
456456

457-
runFrameContext.gameState = SystemArena_MallocDebug(size, __FILE__, __LINE__);
457+
runFrameContext.gameState = SystemArena_MallocDebug(size);
458458

459459
if (!runFrameContext.gameState)
460460
{
@@ -495,7 +495,7 @@ static void RunFrame()
495495

496496
runFrameContext.nextOvl = Graph_GetNextGameState(runFrameContext.gameState);
497497
GameState_Destroy(runFrameContext.gameState);
498-
SystemArena_FreeDebug(runFrameContext.gameState, __FILE__, __LINE__);
498+
SystemArena_FreeDebug(runFrameContext.gameState);
499499
Overlay_FreeGameState(runFrameContext.ovl);
500500
}
501501
Graph_Destroy(&runFrameContext.gfxCtx);

soh/src/code/listalloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ListAlloc* ListAlloc_Init(ListAlloc* this) {
77
}
88

99
void* ListAlloc_Alloc(ListAlloc* this, size_t size) {
10-
ListAlloc* ptr = SystemArena_MallocDebug(size + sizeof(ListAlloc), __FILE__, __LINE__);
10+
ListAlloc* ptr = SystemArena_MallocDebug(size + sizeof(ListAlloc));
1111
ListAlloc* next;
1212

1313
if (ptr == NULL) {
@@ -49,7 +49,7 @@ void ListAlloc_Free(ListAlloc* this, void* data) {
4949
this->next = ptr->prev;
5050
}
5151

52-
SystemArena_FreeDebug(ptr, __FILE__, __LINE__);
52+
SystemArena_FreeDebug(ptr);
5353
}
5454

5555
void ListAlloc_FreeAll(ListAlloc* this) {

soh/src/code/loadfragment2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "global.h"
22

33
void* Overlay_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, void* vRamStart, void* vRamEnd) {
4-
void* allocatedVRamAddr = SystemArena_MallocRDebug((intptr_t)vRamEnd - (intptr_t)vRamStart, __FILE__, __LINE__);
4+
void* allocatedVRamAddr = SystemArena_MallocRDebug((intptr_t)vRamEnd - (intptr_t)vRamStart);
55

66
if (gOverlayLogSeverity >= 3) {
77
osSyncPrintf("OVL:SPEC(%08x-%08x) REAL(%08x-%08x) OFFSET(%08x)\n", vRamStart, vRamEnd, allocatedVRamAddr,

soh/src/code/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void Main(void* arg) {
7575
debugHeapSize = (0x80600000 - (uintptr_t)debugHeap);
7676
} else {
7777
debugHeapSize = 0x400;
78-
debugHeap = SystemArena_MallocDebug(debugHeapSize, __FILE__, __LINE__);
78+
debugHeap = SystemArena_MallocDebug(debugHeapSize);
7979
}
8080

8181
debugHeapSize = 1024 * 64;

soh/src/code/sys_matrix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ MtxF* sMatrixStack; // "Matrix_stack"
2222
MtxF* sCurrentMatrix; // "Matrix_now"
2323

2424
void Matrix_Init(GameState* gameState) {
25-
sCurrentMatrix = GameState_Alloc(gameState, 20 * sizeof(MtxF), __FILE__, __LINE__);
25+
sCurrentMatrix = GameState_Alloc(gameState, 20 * sizeof(MtxF));
2626
sMatrixStack = sCurrentMatrix;
2727
}
2828

soh/src/code/system_malloc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ void* SystemArena_Malloc(size_t size) {
2929
return ptr;
3030
}
3131

32-
void* SystemArena_MallocDebug(size_t size, const char* file, s32 line) {
33-
void* ptr = __osMallocDebug(&gSystemArena, size, file, line);
32+
void* SystemArena_MallocDebug(size_t size) {
33+
void* ptr = __osMallocDebug(&gSystemArena, size, __FILE__, __LINE__);
3434

3535
SystemArena_CheckPointer(ptr, size, "malloc_DEBUG", "確保"); // "Secure"
3636
return ptr;
@@ -43,8 +43,8 @@ void* SystemArena_MallocR(size_t size) {
4343
return ptr;
4444
}
4545

46-
void* SystemArena_MallocRDebug(size_t size, const char* file, s32 line) {
47-
void* ptr = __osMallocRDebug(&gSystemArena, size, file, line);
46+
void* SystemArena_MallocRDebug(size_t size) {
47+
void* ptr = __osMallocRDebug(&gSystemArena, size, __FILE__, __LINE__);
4848

4949
SystemArena_CheckPointer(ptr, size, "malloc_r_DEBUG", "確保"); // "Secure"
5050
return ptr;
@@ -56,8 +56,8 @@ void* SystemArena_Realloc(void* ptr, size_t newSize) {
5656
return ptr;
5757
}
5858

59-
void* SystemArena_ReallocDebug(void* ptr, size_t newSize, const char* file, s32 line) {
60-
ptr = __osReallocDebug(&gSystemArena, ptr, newSize, file, line);
59+
void* SystemArena_ReallocDebug(void* ptr, size_t newSize) {
60+
ptr = __osReallocDebug(&gSystemArena, ptr, newSize, __FILE__, __LINE__);
6161
SystemArena_CheckPointer(ptr, newSize, "realloc_DEBUG", "再確保"); // "Re-securing"
6262
return ptr;
6363
}
@@ -66,8 +66,8 @@ void SystemArena_Free(void* ptr) {
6666
__osFree(&gSystemArena, ptr);
6767
}
6868

69-
void SystemArena_FreeDebug(void* ptr, const char* file, s32 line) {
70-
__osFreeDebug(&gSystemArena, ptr, file, line);
69+
void SystemArena_FreeDebug(void* ptr) {
70+
__osFreeDebug(&gSystemArena, ptr, __FILE__, __LINE__);
7171
}
7272

7373
void* SystemArena_Calloc(size_t num, size_t size) {

0 commit comments

Comments
 (0)