fix arena
This commit is contained in:
parent
b3fe6b4de8
commit
724fd5ed4f
src
|
@ -10,11 +10,11 @@ ArenaAllocator := struct {
|
||||||
size: uint,
|
size: uint,
|
||||||
allocated: uint,
|
allocated: uint,
|
||||||
|
|
||||||
$new := fn(): Self {
|
new := fn(): Self {
|
||||||
allocated := 0
|
size := Target.page_size()
|
||||||
allocated = Target.page_size()
|
// todo(?): spec should accept ?Self as return type
|
||||||
ptr := Target.alloc_zeroed(allocated)
|
ptr := @unwrap(Target.alloc_zeroed(size))
|
||||||
return .(ptr, allocated, 0)
|
return .(ptr, size, 0)
|
||||||
}
|
}
|
||||||
deinit := fn(self: ^Self): void {
|
deinit := fn(self: ^Self): void {
|
||||||
match Target.current() {
|
match Target.current() {
|
||||||
|
|
|
@ -5,8 +5,8 @@ lily := @use("../../lily/lib.hb")
|
||||||
|
|
||||||
main := fn(argc: int, argv: [][]u8): u8 {
|
main := fn(argc: int, argv: [][]u8): u8 {
|
||||||
alloc := lily.alloc.ArenaAllocator.new()
|
alloc := lily.alloc.ArenaAllocator.new()
|
||||||
|
defer alloc.deinit()
|
||||||
ptr_one := alloc.alloc(u8, 6)
|
ptr_one := alloc.alloc(u8, 6)
|
||||||
ptr_two := alloc.alloc(u8, 179)
|
ptr_two := alloc.alloc(u8, 179)
|
||||||
alloc.deinit()
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
Loading…
Reference in a new issue