fix ArenaAllocator

This commit is contained in:
Andrew Kelley 2019-06-22 01:13:10 -04:00
parent b5f9033d82
commit 726674b2bd
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 15 additions and 15 deletions

View File

@ -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" {

View File

@ -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");