ArenaAllocator: use full capacity
This commit is contained in:
committed by
Andrew Kelley
parent
35e8876c23
commit
67e97a1f0f
@@ -49,9 +49,8 @@ pub const ArenaAllocator = struct {
|
||||
const actual_min_size = minimum_size + (@sizeOf(BufNode) + 16);
|
||||
const big_enough_len = prev_len + actual_min_size;
|
||||
const len = big_enough_len + big_enough_len / 2;
|
||||
const buf = try self.child_allocator.alignedAlloc(u8, @alignOf(BufNode), len);
|
||||
const buf_node_slice = mem.bytesAsSlice(BufNode, buf[0..@sizeOf(BufNode)]);
|
||||
const buf_node = &buf_node_slice[0];
|
||||
const buf = try self.child_allocator.callAllocFn(len, @alignOf(BufNode), 1);
|
||||
const buf_node = @ptrCast(*BufNode, @alignCast(@alignOf(BufNode), buf.ptr));
|
||||
buf_node.* = BufNode{
|
||||
.data = buf,
|
||||
.next = null,
|
||||
|
||||
Reference in New Issue
Block a user