Fix Arena realloc bug
This commit is contained in:
@@ -77,11 +77,7 @@ void *ArenaAllocator::realloc_raw(void *ptr, uint32_t old_size,
|
|||||||
assert(current_block_ &&
|
assert(current_block_ &&
|
||||||
"realloc called with non-null ptr but no current block exists");
|
"realloc called with non-null ptr but no current block exists");
|
||||||
|
|
||||||
// Assert that offset is large enough (should always be true for
|
if (current_block_->offset >= old_size) {
|
||||||
// valid callers)
|
|
||||||
assert(current_block_->offset >= old_size &&
|
|
||||||
"offset must be >= old_size for valid last allocation");
|
|
||||||
|
|
||||||
// Check if this was the last allocation by comparing with expected location
|
// Check if this was the last allocation by comparing with expected location
|
||||||
char *expected_last_alloc_start =
|
char *expected_last_alloc_start =
|
||||||
current_block_->data() + current_block_->offset - old_size;
|
current_block_->data() + current_block_->offset - old_size;
|
||||||
@@ -105,6 +101,7 @@ void *ArenaAllocator::realloc_raw(void *ptr, uint32_t old_size,
|
|||||||
return new_size == 0 ? nullptr : ptr;
|
return new_size == 0 ? nullptr : ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Can't extend in place
|
// Can't extend in place
|
||||||
if (new_size == 0) {
|
if (new_size == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user