T() macro 5 (#2089)

* T() in __osMalloc.c

* T() in code_80097A00.c

* T() in debug_malloc.c

* T() in code/load.c

* T() in sys_math3d.c

* T() in z_collision_btltbls.c, z_fbdemo_fade.c, z_fcurve_data_skelanime.c, z_view.c

* T() in z_collision_check.c

* remaining T() in __osMalloc.c

* __osMalloc consistency

* format
This commit is contained in:
Dragorn421
2024-08-27 14:32:33 +02:00
committed by GitHub
parent d2aca2239f
commit fd14ddcbf1
10 changed files with 104 additions and 91 deletions
+40 -31
View File
@@ -126,7 +126,9 @@ ArenaNode* ArenaImpl_GetNextBlock(ArenaNode* node) {
ArenaNode* next = node->next;
if (next != NULL && (next == NULL || (next->magic != NODE_MAGIC))) {
osSyncPrintf(VT_COL(RED, WHITE) "緊急事態!メモリリーク発見! (block=%08x)\n" VT_RST, next);
osSyncPrintf(VT_COL(RED, WHITE) T("緊急事態!メモリリーク発見! (block=%08x)\n",
"Emergency! Memory leak detected! (block=%08x)\n") VT_RST,
next);
next = NULL;
node->next = NULL;
}
@@ -137,7 +139,9 @@ ArenaNode* ArenaImpl_GetPrevBlock(ArenaNode* node) {
ArenaNode* prev = node->prev;
if (prev != NULL && (prev == NULL || (prev->magic != NODE_MAGIC))) {
osSyncPrintf(VT_COL(RED, WHITE) "緊急事態!メモリリーク発見! (block=%08x)\n" VT_RST, prev);
osSyncPrintf(VT_COL(RED, WHITE) T("緊急事態!メモリリーク発見! (block=%08x)\n",
"Emergency! Memory leak detected! (block=%08x)\n") VT_RST,
prev);
prev = NULL;
node->prev = NULL;
}
@@ -243,9 +247,10 @@ void __osMalloc_FreeBlockTest(Arena* arena, ArenaNode* node) {
while (iter < end) {
if (*iter != BLOCK_UNINIT_MAGIC_32 && *iter != BLOCK_FREE_MAGIC_32) {
osSyncPrintf(
VT_COL(RED, WHITE) "緊急事態!メモリリーク検出! (block=%08x s=%08x e=%08x p=%08x)\n" VT_RST, node,
start, end, iter);
osSyncPrintf(VT_COL(RED, WHITE)
T("緊急事態!メモリリーク検出! (block=%08x s=%08x e=%08x p=%08x)\n",
"Emergency! Memory leak detected! (block=%08x s=%08x e=%08x p=%08x)\n") VT_RST,
node, start, end, iter);
__osDisplayArena(arena);
return;
}
@@ -475,19 +480,20 @@ void __osFree_NoLock(Arena* arena, void* ptr) {
node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode));
if (node == NULL || node->magic != NODE_MAGIC) {
// "__osFree: Unauthorized release (%08x)"
PRINTF(VT_COL(RED, WHITE) "__osFree:不正解放(%08x)\n" VT_RST, ptr);
PRINTF(VT_COL(RED, WHITE) T("__osFree:不正解放(%08x)\n", "__osFree: Unauthorized release (%08x)\n") VT_RST,
ptr);
return;
}
if (node->isFree) {
PRINTF(VT_COL(RED, WHITE) "__osFree:二重解放(%08x)\n" VT_RST, ptr); // "__osFree: Double release (%08x)"
PRINTF(VT_COL(RED, WHITE) T("__osFree:二重解放(%08x)\n", "__osFree: Double release (%08x)\n") VT_RST, ptr);
return;
}
#if OOT_DEBUG
if (arena != node->arena && arena != NULL) {
// "__osFree:Tried to release in a different way than when it was secured (%08x:%08x)"
PRINTF(VT_COL(RED, WHITE) "__osFree:確保時と違う方法で解放しようとした (%08x:%08x)\n" VT_RST, arena,
node->arena);
PRINTF(VT_COL(RED, WHITE)
T("__osFree:確保時と違う方法で解放しようとした (%08x:%08x)\n",
"__osFree:Tried to release in a different way than when it was secured (%08x:%08x)\n") VT_RST,
arena, node->arena);
return;
}
#endif
@@ -540,19 +546,22 @@ void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, int line) {
node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode));
if (node == NULL || node->magic != NODE_MAGIC) {
// "__osFree: Unauthorized release (%08x)"
PRINTF(VT_COL(RED, WHITE) "__osFree:不正解放(%08x) [%s:%d ]\n" VT_RST, ptr, file, line);
PRINTF(VT_COL(RED, WHITE)
T("__osFree:不正解放(%08x) [%s:%d ]\n", "__osFree: Unauthorized release (%08x) [%s:%d ]\n") VT_RST,
ptr, file, line);
return;
}
if (node->isFree) {
// "__osFree: Double release (%08x)"
PRINTF(VT_COL(RED, WHITE) "__osFree:二重解放(%08x) [%s:%d ]\n" VT_RST, ptr, file, line);
PRINTF(VT_COL(RED, WHITE) T("__osFree:二重解放(%08x) [%s:%d ]\n", "__osFree: Double release (%08x) [%s:%d ]\n")
VT_RST,
ptr, file, line);
return;
}
if (arena != node->arena && arena != NULL) {
// "__osFree:Tried to release in a different way than when it was secured (%08x:%08x)"
PRINTF(VT_COL(RED, WHITE) "__osFree:確保時と違う方法で解放しようとした (%08x:%08x)\n" VT_RST, arena,
node->arena);
PRINTF(VT_COL(RED, WHITE)
T("__osFree:確保時と違う方法で解放しようとした (%08x:%08x)\n",
"__osFree:Tried to release in a different way than when it was secured (%08x:%08x)\n") VT_RST,
arena, node->arena);
return;
}
@@ -619,14 +628,14 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
} else {
node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode));
if (newSize == node->size) {
// "Does nothing because the memory block size does not change"
osSyncPrintf("メモリブロックサイズが変わらないためなにもしません\n");
osSyncPrintf(T("メモリブロックサイズが変わらないためなにもしません\n",
"Does nothing because the memory block size does not change\n"));
} else if (node->size < newSize) {
next = NODE_GET_NEXT(node);
sizeDiff = newSize - node->size;
if ((u32)next == ((u32)node + node->size + sizeof(ArenaNode)) && next->isFree && next->size >= sizeDiff) {
// "Merge because there is a free block after the current memory block"
osSyncPrintf("現メモリブロックの後ろにフリーブロックがあるので結合します\n");
osSyncPrintf(T("現メモリブロックの後ろにフリーブロックがあるので結合します\n",
"Merge because there is a free block after the current memory block\n"));
next->size -= sizeDiff;
overNext = NODE_GET_NEXT(next);
newNext = (ArenaNode*)((u32)next + sizeDiff);
@@ -637,8 +646,8 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
node->size = newSize;
memmove(node->next, next, sizeof(ArenaNode));
} else {
// "Allocate a new memory block and move the contents"
osSyncPrintf("新たにメモリブロックを確保して内容を移動します\n");
osSyncPrintf(T("新たにメモリブロックを確保して内容を移動します\n",
"Allocate a new memory block and move the contents\n"));
newAlloc = __osMalloc_NoLock(arena, newSize);
if (newAlloc != NULL) {
bcopy(ptr, newAlloc, node->size);
@@ -651,8 +660,8 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
if (next2 != NULL && next2->isFree) {
blockSize = ALIGN16(newSize) + sizeof(ArenaNode);
// "Increased free block behind current memory block"
osSyncPrintf("現メモリブロックの後ろのフリーブロックを大きくしました\n");
osSyncPrintf(T("現メモリブロックの後ろのフリーブロックを大きくしました\n",
"Increased free block behind current memory block\n"));
newNext2 = (ArenaNode*)((u32)node + blockSize);
localCopy = *next2;
*newNext2 = localCopy;
@@ -666,8 +675,8 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
} else if (newSize + sizeof(ArenaNode) < node->size) {
blockSize = ALIGN16(newSize) + sizeof(ArenaNode);
// "Generated because there is no free block after the current memory block"
osSyncPrintf("現メモリブロックの後ろにフリーブロックがないので生成します\n");
osSyncPrintf(T("現メモリブロックの後ろにフリーブロックがないので生成します\n",
"Generated because there is no free block after the current memory block\n"));
newNext2 = (ArenaNode*)((u32)node + blockSize);
newNext2->next = NODE_GET_NEXT(node);
newNext2->prev = node;
@@ -681,8 +690,8 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
overNext2->prev = newNext2;
}
} else {
// "There is no room to generate free blocks"
osSyncPrintf("フリーブロック生成するだけの空きがありません\n");
osSyncPrintf(
T("フリーブロック生成するだけの空きがありません\n", "There is no room to generate free blocks\n"));
ptr = NULL;
}
}
@@ -735,7 +744,7 @@ void __osDisplayArena(Arena* arena) {
ArenaNode* next;
if (!__osMallocIsInitialized(arena)) {
osSyncPrintf("アリーナは初期化されていません\n"); // "Arena is not initialized"
osSyncPrintf(T("アリーナは初期化されていません\n", "Arena is not initialized\n"));
return;
}