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