fix ArenaAllocator
This commit is contained in:
parent
b5f9033d82
commit
726674b2bd
28
std/heap.zig
28
std/heap.zig
@ -368,9 +368,9 @@ pub const ArenaAllocator = struct {
|
|||||||
var it = self.buffer_list.first;
|
var it = self.buffer_list.first;
|
||||||
while (it) |node| {
|
while (it) |node| {
|
||||||
// this has to occur before the free because the free frees 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);
|
self.child_allocator.free(node.data);
|
||||||
|
it = next_it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,18 +764,18 @@ test "HeapAllocator" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//test "ArenaAllocator" {
|
test "ArenaAllocator" {
|
||||||
// var direct_allocator = DirectAllocator.init();
|
var direct_allocator = DirectAllocator.init();
|
||||||
// defer direct_allocator.deinit();
|
defer direct_allocator.deinit();
|
||||||
//
|
|
||||||
// var arena_allocator = ArenaAllocator.init(&direct_allocator.allocator);
|
var arena_allocator = ArenaAllocator.init(&direct_allocator.allocator);
|
||||||
// defer arena_allocator.deinit();
|
defer arena_allocator.deinit();
|
||||||
//
|
|
||||||
// try testAllocator(&arena_allocator.allocator);
|
try testAllocator(&arena_allocator.allocator);
|
||||||
// try testAllocatorAligned(&arena_allocator.allocator, 16);
|
try testAllocatorAligned(&arena_allocator.allocator, 16);
|
||||||
// try testAllocatorLargeAlignment(&arena_allocator.allocator);
|
try testAllocatorLargeAlignment(&arena_allocator.allocator);
|
||||||
// try testAllocatorAlignedShrink(&arena_allocator.allocator);
|
try testAllocatorAlignedShrink(&arena_allocator.allocator);
|
||||||
//}
|
}
|
||||||
|
|
||||||
var test_fixed_buffer_allocator_memory: [80000 * @sizeOf(u64)]u8 = undefined;
|
var test_fixed_buffer_allocator_memory: [80000 * @sizeOf(u64)]u8 = undefined;
|
||||||
test "FixedBufferAllocator" {
|
test "FixedBufferAllocator" {
|
||||||
|
@ -88,7 +88,7 @@ test "std" {
|
|||||||
_ = @import("fmt.zig");
|
_ = @import("fmt.zig");
|
||||||
_ = @import("fs.zig");
|
_ = @import("fs.zig");
|
||||||
_ = @import("hash.zig");
|
_ = @import("hash.zig");
|
||||||
_ = @import("heap.zig"); // TODO commented test
|
_ = @import("heap.zig");
|
||||||
_ = @import("io.zig");
|
_ = @import("io.zig");
|
||||||
//_ = @import("json.zig");
|
//_ = @import("json.zig");
|
||||||
//_ = @import("lazy_init.zig");
|
//_ = @import("lazy_init.zig");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user