forked from AbleOS/ableos
26 lines
565 B
Plaintext
26 lines
565 B
Plaintext
|
allocators := @use("alloc/alloc.hb")
|
||
|
|
||
|
AStruct := struct {
|
||
|
a_field: u8,
|
||
|
}
|
||
|
|
||
|
main := fn():void{
|
||
|
alloc := allocators.FakeAlloc.init()
|
||
|
astruct := alloc.alloc(AStruct, 2)
|
||
|
if astruct.ptr != null{
|
||
|
panic("FakeAlloc actually allocated.")
|
||
|
}
|
||
|
alloc.dealloc(astruct_ptr, AStruct, 2)
|
||
|
alloc.deinit()
|
||
|
|
||
|
balloc := allocators.BlockAlloc.init()
|
||
|
bstruct_ptr := balloc.alloc(AStruct, 2)
|
||
|
if bstruct_ptr == null {
|
||
|
panic("BlockAlloc actually didn't allocate.")
|
||
|
}
|
||
|
balloc.dealloc(bstruct_ptr, AStruct, 2)
|
||
|
balloc.deinit()
|
||
|
|
||
|
|
||
|
}
|