Minor fix to heap_allocator_proc in common_memory.cpp

This commit is contained in:
gingerBill
2021-09-06 16:50:13 +01:00
parent bc15ce302c
commit f5615b204c
+14 -4
View File
@@ -350,11 +350,16 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) {
gb_zero_size(ptr, size); gb_zero_size(ptr, size);
} break; } break;
case gbAllocation_Free: { case gbAllocation_Free:
free(old_memory); if (!old_memory) {
} break; free(old_memory);
}
break;
case gbAllocation_Resize: case gbAllocation_Resize:
if (!old_memory) {
break;
}
if (size == 0) { if (size == 0) {
free(old_memory); free(old_memory);
break; break;
@@ -381,10 +386,15 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) {
break; break;
case gbAllocation_Free: case gbAllocation_Free:
free(old_memory); if (!old_memory) {
free(old_memory);
}
break; break;
case gbAllocation_Resize: case gbAllocation_Resize:
if (!old_memory) {
break;
}
if (size == 0) { if (size == 0) {
free(old_memory); free(old_memory);
break; break;