diff options
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; |
