Files
brolang/examples/programs/heap/main.bro
T

21 lines
264 B
Plaintext

heap :: import "@std/mem/heap"
main func() i32 {
memory ?*mut u8 = heap.alloc(4)
defer heap.free(memory)
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
}