function literals (non-capturing)
This commit is contained in:
+6
-10
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user