Commit 726674b2bd
std/heap.zig
@@ -368,9 +368,9 @@ pub const ArenaAllocator = struct {
var it = self.buffer_list.first;
while (it) |node| {
// this has to occur before the free because the free frees node
- it = node.next;
-
+ const next_it = node.next;
self.child_allocator.free(node.data);
+ it = next_it;
}
}
@@ -764,18 +764,18 @@ test "HeapAllocator" {
}
}
-//test "ArenaAllocator" {
-// var direct_allocator = DirectAllocator.init();
-// defer direct_allocator.deinit();
-//
-// var arena_allocator = ArenaAllocator.init(&direct_allocator.allocator);
-// defer arena_allocator.deinit();
-//
-// try testAllocator(&arena_allocator.allocator);
-// try testAllocatorAligned(&arena_allocator.allocator, 16);
-// try testAllocatorLargeAlignment(&arena_allocator.allocator);
-// try testAllocatorAlignedShrink(&arena_allocator.allocator);
-//}
+test "ArenaAllocator" {
+ var direct_allocator = DirectAllocator.init();
+ defer direct_allocator.deinit();
+
+ var arena_allocator = ArenaAllocator.init(&direct_allocator.allocator);
+ defer arena_allocator.deinit();
+
+ try testAllocator(&arena_allocator.allocator);
+ try testAllocatorAligned(&arena_allocator.allocator, 16);
+ try testAllocatorLargeAlignment(&arena_allocator.allocator);
+ try testAllocatorAlignedShrink(&arena_allocator.allocator);
+}
var test_fixed_buffer_allocator_memory: [80000 * @sizeOf(u64)]u8 = undefined;
test "FixedBufferAllocator" {
std/std.zig
@@ -88,7 +88,7 @@ test "std" {
_ = @import("fmt.zig");
_ = @import("fs.zig");
_ = @import("hash.zig");
- _ = @import("heap.zig"); // TODO commented test
+ _ = @import("heap.zig");
_ = @import("io.zig");
//_ = @import("json.zig");
//_ = @import("lazy_init.zig");