mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 22:33:08 +00:00
std.heap.raw_c_allocator: use malloc_size for resize
std.heap.c_allocator was already doing this, however, std.heap.raw_c_allocator, which asserts no allocations more than 16 bytes aligned, was not. The zig compiler uses std.heap.raw_c_allocator, so it is affected by this.
This commit is contained in:
parent
f6af773578
commit
9d7082972e
@ -196,7 +196,16 @@ fn rawCResize(
|
|||||||
) bool {
|
) bool {
|
||||||
_ = log2_old_align;
|
_ = log2_old_align;
|
||||||
_ = ret_addr;
|
_ = ret_addr;
|
||||||
return new_len <= buf.len;
|
|
||||||
|
if (new_len <= buf.len)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (CAllocator.supports_malloc_size) {
|
||||||
|
const full_len = CAllocator.malloc_size(buf.ptr);
|
||||||
|
if (new_len <= full_len) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rawCFree(
|
fn rawCFree(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user