aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-09-06 19:34:44 +0100
committergingerBill <bill@gingerbill.org>2021-09-06 19:34:44 +0100
commit97a11475371c13cee565803dcc24ef137b932484 (patch)
tree864dea9d71c56c90a2378a3f6886d99568784642 /src
parentb63d49aafa27a97ef47e217443908901a6930023 (diff)
Correct fix to `heap_allocator_proc` in compiler
Diffstat (limited to 'src')
-rw-r--r--src/common_memory.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/common_memory.cpp b/src/common_memory.cpp
index bd3d2d5de..418470c19 100644
--- a/src/common_memory.cpp
+++ b/src/common_memory.cpp
@@ -351,20 +351,19 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) {
} break;
case gbAllocation_Free:
- if (!old_memory) {
+ if (old_memory != nullptr) {
free(old_memory);
}
break;
case gbAllocation_Resize:
- if (!old_memory) {
- break;
- }
if (size == 0) {
- free(old_memory);
+ if (old_memory != nullptr) {
+ free(old_memory);
+ }
break;
}
- if (!old_memory) {
+ if (old_memory == nullptr) {
ptr = aligned_alloc(alignment, (size + alignment - 1) & ~(alignment - 1));
gb_zero_size(ptr, size);
break;
@@ -386,20 +385,17 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) {
break;
case gbAllocation_Free:
- if (!old_memory) {
+ if (old_memory != nullptr) {
free(old_memory);
}
break;
case gbAllocation_Resize:
- if (!old_memory) {
- break;
- }
if (size == 0) {
free(old_memory);
break;
}
- if (!old_memory) {
+ if (old_memory == nullptr) {
posix_memalign(&ptr, alignment, size);
gb_zero_size(ptr, size);
break;