aboutsummaryrefslogtreecommitdiff
path: root/std/heap.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-06-11 00:09:58 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-06-11 00:09:58 -0400
commit33371ab55c01d896b91df13eafe6e5c601400a07 (patch)
tree879666e7729aaef2273e8c336b425909df3d2022 /std/heap.zig
parentd504318f2e0f3054c772abbd34f938f2cefa6ccc (diff)
parent34a22a85ca8d4371fe9b8f921cce858ab4351cca (diff)
downloadzig-33371ab55c01d896b91df13eafe6e5c601400a07.tar.gz
zig-33371ab55c01d896b91df13eafe6e5c601400a07.zip
Merge remote-tracking branch 'origin/master' into copy-elision-3
Diffstat (limited to 'std/heap.zig')
-rw-r--r--std/heap.zig11
1 files changed, 5 insertions, 6 deletions
diff --git a/std/heap.zig b/std/heap.zig
index 7d7774f453..b35abd138c 100644
--- a/std/heap.zig
+++ b/std/heap.zig
@@ -347,10 +347,10 @@ pub const ArenaAllocator = struct {
pub allocator: Allocator,
child_allocator: *Allocator,
- buffer_list: std.LinkedList([]u8),
+ buffer_list: std.SinglyLinkedList([]u8),
end_index: usize,
- const BufNode = std.LinkedList([]u8).Node;
+ const BufNode = std.SinglyLinkedList([]u8).Node;
pub fn init(child_allocator: *Allocator) ArenaAllocator {
return ArenaAllocator{
@@ -359,7 +359,7 @@ pub const ArenaAllocator = struct {
.shrinkFn = shrink,
},
.child_allocator = child_allocator,
- .buffer_list = std.LinkedList([]u8).init(),
+ .buffer_list = std.SinglyLinkedList([]u8).init(),
.end_index = 0,
};
}
@@ -387,10 +387,9 @@ pub const ArenaAllocator = struct {
const buf_node = &buf_node_slice[0];
buf_node.* = BufNode{
.data = buf,
- .prev = null,
.next = null,
};
- self.buffer_list.append(buf_node);
+ self.buffer_list.prepend(buf_node);
self.end_index = 0;
return buf_node;
}
@@ -398,7 +397,7 @@ pub const ArenaAllocator = struct {
fn alloc(allocator: *Allocator, n: usize, alignment: u29) ![]u8 {
const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator);
- var cur_node = if (self.buffer_list.last) |last_node| last_node else try self.createNode(0, n + alignment);
+ var cur_node = if (self.buffer_list.first) |first_node| first_node else try self.createNode(0, n + alignment);
while (true) {
const cur_buf = cur_node.data[@sizeOf(BufNode)..];
const addr = @ptrToInt(cur_buf.ptr) + self.end_index;