authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-24 18:21:08-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-25 05:38:28-08:00
log9d7082972e8df9105b48a806e7bfabca90d4dc1b
tree002f93ef63b51f8459b0d9c77520aab593d31d3d
parentf6af773578e20dbae3bf2a350c036558fea84803

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.

1 files changed, 10 insertions(+), 1 deletions(-)

lib/std/heap.zig+10-1
......@@ -196,7 +196,16 @@ fn rawCResize(
196196) bool {
197197 _ = log2_old_align;
198198 _ = ret_addr;
199 return new_len <= buf.len;
199
200 if (new_len <= buf.len)
201 return true;
202
203 if (CAllocator.supports_malloc_size) {
204 const full_len = CAllocator.malloc_size(buf.ptr);
205 if (new_len <= full_len) return true;
206 }
207
208 return false;
200209}
201210
202211fn rawCFree(