function literals (non-capturing)

This commit is contained in:
2026-07-07 17:04:38 +02:00
parent 95c61311ca
commit f171a6579d
5 changed files with 186 additions and 20 deletions
+6 -10
View File
@@ -8,16 +8,12 @@ Allocator :: struct {
heap Allocator :: Allocator {
context = none,
alloc = heap_alloc,
free = heap_free,
}
heap_alloc func(context ?*mut anyopaque, size usize, alignment usize) ?*mut u8 {
return ptr_cast(u8, c.malloc(size))
}
heap_free func(context ?*mut anyopaque, memory ?*mut u8, size usize, alignment usize) void {
c.free(memory)
alloc = func(context ?*mut anyopaque, size usize, alignment usize) ?*mut u8 {
return ptr_cast(u8, c.malloc(size))
},
free = func(context ?*mut anyopaque, memory ?*mut u8, size usize, alignment usize) void {
c.free(memory)
},
}
alloc func(allocator Allocator, size usize, alignment usize) ?*mut u8 {