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/gamealloc.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/gamealloc.c')
| -rw-r--r-- | src/code/gamealloc.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/code/gamealloc.c b/src/code/gamealloc.c index 960aeea98..9a4303ad2 100644 --- a/src/code/gamealloc.c +++ b/src/code/gamealloc.c @@ -13,10 +13,9 @@ void GameAlloc_Log(GameAlloc* this) { } void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 line) { - GameAllocEntry* ptr; + GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), file, line); - ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), file, line); - if (ptr) { + if (ptr != NULL) { ptr->size = size; ptr->prev = this->head; this->head->next = ptr; @@ -30,10 +29,9 @@ void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 lin } void* GameAlloc_Malloc(GameAlloc* this, u32 size) { - GameAllocEntry* ptr; + GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), "../gamealloc.c", 93); - ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), "../gamealloc.c", 93); - if (ptr) { + if (ptr != NULL) { ptr->size = size; ptr->prev = this->head; this->head->next = ptr; @@ -49,7 +47,7 @@ void* GameAlloc_Malloc(GameAlloc* this, u32 size) { void GameAlloc_Free(GameAlloc* this, void* data) { GameAllocEntry* ptr; - if (data) { + if (data != NULL) { ptr = &((GameAllocEntry*)data)[-1]; LogUtils_CheckNullPointer("ptr->prev", ptr->prev, "../gamealloc.c", 120); LogUtils_CheckNullPointer("ptr->next", ptr->next, "../gamealloc.c", 121); @@ -61,10 +59,9 @@ void GameAlloc_Free(GameAlloc* this, void* data) { } void GameAlloc_Cleanup(GameAlloc* this) { - GameAllocEntry* next; + GameAllocEntry* next = this->base.next; GameAllocEntry* cur; - next = this->base.next; while (&this->base != next) { cur = next; next = next->next; |
