allocator interface (first pass)
This commit is contained in:
@@ -78,11 +78,11 @@ increment func(value i32) i32 {
|
||||
return value + 1
|
||||
}
|
||||
|
||||
call_native func(callback *func(value i32) i32, value i32) i32 {
|
||||
call_native func(callback @func(value i32) i32, value i32) i32 {
|
||||
return callback(value)
|
||||
}
|
||||
|
||||
call_fallible func(callback *func(flag bool) i32 ! Error, flag bool) i32 ! Error {
|
||||
call_fallible func(callback @func(flag bool) i32 ! Error, flag bool) i32 ! Error {
|
||||
return try callback(flag)
|
||||
}
|
||||
|
||||
|
||||
@@ -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