diff options
Diffstat (limited to 'src/code/__osMalloc.c')
| -rw-r--r-- | src/code/__osMalloc.c | 71 |
1 files changed, 40 insertions, 31 deletions
diff --git a/src/code/__osMalloc.c b/src/code/__osMalloc.c index c70b5ce77..951a4b077 100644 --- a/src/code/__osMalloc.c +++ b/src/code/__osMalloc.c @@ -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; } |
