allocator interface (first pass)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
mem :: import "@std/mem"
|
||||
|
||||
main func() i32 {
|
||||
memory ?*mut u8 = mem.alloc(mem.heap, 4, 1)
|
||||
defer mem.free(mem.heap, memory, 4, 1)
|
||||
|
||||
if memory |bytes| {
|
||||
bytes[0] = 10
|
||||
bytes[1] = 20
|
||||
bytes[2] = bytes[0] + bytes[1]
|
||||
|
||||
if (bytes[2] != 30) {
|
||||
return 2
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
Reference in New Issue
Block a user