diff options
| author | Tharo <17233964+Thar0@users.noreply.github.com> | 2021-02-14 00:49:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-13 19:49:40 -0500 |
| commit | f9d96d9f73ac090245a518ec04f3fa0e50655d1e (patch) | |
| tree | 9dc905fce276cbfb07a05fc2bf0883bcedddcf23 /src/code/debug_malloc.c | |
| parent | d615ec4f31563b939f8c0dce1c20c79e137c2043 (diff) | |
Fix most compiler warnings in the boot and code segments (#674)
* Less warnings in boot & code segments
* few more warnings gone
* Ran formatter
* z_view warning gone
* -> 1
* f31 -> 31
* Remove function casts
* Few more small improvements
* Separate declaration and assignment in func_80091738 and Item_Give
Co-authored-by: Thar0 <maximilianc64@gmail.com>
Diffstat (limited to 'src/code/debug_malloc.c')
| -rw-r--r-- | src/code/debug_malloc.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/code/debug_malloc.c b/src/code/debug_malloc.c index 827f10a40..d92ec42bf 100644 --- a/src/code/debug_malloc.c +++ b/src/code/debug_malloc.c @@ -8,7 +8,7 @@ s32 gDebugArenaLogSeverity = LOG_SEVERITY_ERROR; Arena sDebugArena; void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action) { - if (!ptr) { + if (ptr == NULL) { if (gDebugArenaLogSeverity >= LOG_SEVERITY_ERROR) { // "%s: %u bytes %s failed\n" osSyncPrintf("%s: %u バイトの%sに失敗しました\n", name, size, action); @@ -22,29 +22,29 @@ void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* } void* DebugArena_Malloc(u32 size) { - void* ptr; - ptr = __osMalloc(&sDebugArena, size); + void* ptr = __osMalloc(&sDebugArena, size); + DebugArena_CheckPointer(ptr, size, "debug_malloc", "確保"); // Secure return ptr; } void* DebugArena_MallocDebug(u32 size, const char* file, s32 line) { - void* ptr; - ptr = __osMallocDebug(&sDebugArena, size, file, line); + void* ptr = __osMallocDebug(&sDebugArena, size, file, line); + DebugArena_CheckPointer(ptr, size, "debug_malloc_DEBUG", "確保"); // Secure return ptr; } void* DebugArena_MallocR(u32 size) { - void* ptr; - ptr = __osMallocR(&sDebugArena, size); + void* ptr = __osMallocR(&sDebugArena, size); + DebugArena_CheckPointer(ptr, size, "debug_malloc_r", "確保"); // Secure return ptr; } void* DebugArena_MallocRDebug(u32 size, const char* file, s32 line) { - void* ptr; - ptr = __osMallocRDebug(&sDebugArena, size, file, line); + void* ptr = __osMallocRDebug(&sDebugArena, size, file, line); + DebugArena_CheckPointer(ptr, size, "debug_malloc_r_DEBUG", "確保"); // Secure return ptr; } @@ -71,11 +71,10 @@ void DebugArena_FreeDebug(void* ptr, const char* file, s32 line) { void* DebugArena_Calloc(u32 num, u32 size) { void* ret; - u32 n; + u32 n = num * size; - n = num * size; ret = __osMalloc(&sDebugArena, n); - if (ret) { + if (ret != NULL) { bzero(ret, n); } @@ -83,7 +82,7 @@ void* DebugArena_Calloc(u32 num, u32 size) { return ret; } -void DebugArena_Display() { +void DebugArena_Display(void) { // Zelda heap display (devs forgot to change "Zelda" to "Debug" apparently) osSyncPrintf("ゼルダヒープ表示\n"); __osDisplayArena(&sDebugArena); @@ -93,7 +92,7 @@ void DebugArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc) { ArenaImpl_GetSizes(&sDebugArena, outMaxFree, outFree, outAlloc); } -void DebugArena_Check() { +void DebugArena_Check(void) { __osCheckArena(&sDebugArena); } @@ -102,11 +101,11 @@ void DebugArena_Init(void* start, u32 size) { __osMallocInit(&sDebugArena, start, size); } -void DebugArena_Cleanup() { +void DebugArena_Cleanup(void) { gDebugArenaLogSeverity = LOG_SEVERITY_NOLOG; __osMallocCleanup(&sDebugArena); } -u8 DebugArena_IsInitalized() { +u8 DebugArena_IsInitalized(void) { return __osMallocIsInitalized(&sDebugArena); } |
