Commit 67e97a1f0f

Jonathan Marler <johnnymarler@gmail.com>
2020-06-29 07:44:48
ArenaAllocator: use full capacity
1 parent 35e8876
Changed files (1)
lib
lib/std/heap/arena_allocator.zig
@@ -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,