diff options
| author | Jonathan Marler <johnnymarler@gmail.com> | 2020-06-28 23:44:48 -0600 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-06-29 05:12:30 -0400 |
| commit | 67e97a1f0fe661b05234e24a58be15d9b48588f2 (patch) | |
| tree | 298603cf42a4bdd221466d9ea22f44cfd800d070 /lib/std | |
| parent | 35e8876c23e53c11115c78ff3984effa965a8cca (diff) | |
| download | zig-67e97a1f0fe661b05234e24a58be15d9b48588f2.tar.gz zig-67e97a1f0fe661b05234e24a58be15d9b48588f2.zip | |
ArenaAllocator: use full capacity
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/heap/arena_allocator.zig | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/std/heap/arena_allocator.zig b/lib/std/heap/arena_allocator.zig index 74ced774ed..a5d8aaea45 100644 --- a/lib/std/heap/arena_allocator.zig +++ b/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, |
