|
|
|
@ -257,14 +257,14 @@ void *Util::heap_realloc(void *h, void *ptr, size_t new_size)
@@ -257,14 +257,14 @@ void *Util::heap_realloc(void *h, void *ptr, size_t new_size)
|
|
|
|
|
old_size = old_header->allocation_size; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
heapp->current_heap_usage -= old_size; |
|
|
|
|
if (new_size == 0) { |
|
|
|
|
free(old_header); |
|
|
|
|
if ((heapp->current_heap_usage + new_size - old_size) > heapp->max_heap_size) { |
|
|
|
|
// fail the allocation as we don't have the memory. Note that we don't simulate fragmentation
|
|
|
|
|
return nullptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((heapp->current_heap_usage + new_size - old_size) > heapp->max_heap_size) { |
|
|
|
|
// fail the allocation as we don't have the memory. Note that we don't simulate fragmentation
|
|
|
|
|
heapp->current_heap_usage -= old_size; |
|
|
|
|
if (new_size == 0) { |
|
|
|
|
free(old_header); |
|
|
|
|
return nullptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|