mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Remove unnecessary free.
This commit is contained in:
@@ -48,14 +48,7 @@ fn void*? LibcAllocator.acquire(&self, usz bytes, AllocInitType init_type, usz a
|
|||||||
|
|
||||||
fn void*? LibcAllocator.resize(&self, void* old_ptr, usz new_bytes, usz alignment) @dynamic
|
fn void*? LibcAllocator.resize(&self, void* old_ptr, usz new_bytes, usz alignment) @dynamic
|
||||||
{
|
{
|
||||||
if (alignment <= mem::DEFAULT_MEM_ALIGNMENT) return libc::realloc(old_ptr, new_bytes) ?: mem::OUT_OF_MEMORY~;
|
if (alignment <= mem::DEFAULT_MEM_ALIGNMENT) return libc::realloc(old_ptr, new_bytes) ?: mem::OUT_OF_MEMORY~;
|
||||||
|
|
||||||
// Easy case, it's 0
|
|
||||||
if (!new_bytes)
|
|
||||||
{
|
|
||||||
libc::free(old_ptr);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try realloc, even though it might be unaligned.
|
// Try realloc, even though it might be unaligned.
|
||||||
void* new_ptr = libc::realloc(old_ptr, new_bytes) ?: mem::OUT_OF_MEMORY~!;
|
void* new_ptr = libc::realloc(old_ptr, new_bytes) ?: mem::OUT_OF_MEMORY~!;
|
||||||
|
|||||||
Reference in New Issue
Block a user