allocator interface (first pass)

This commit is contained in:
2026-07-06 21:24:49 +02:00
parent 7ce3917c15
commit 95c61311ca
24 changed files with 833 additions and 161 deletions
+2 -2
View File
@@ -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)
}
+20
View File
@@ -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
}