split up mem_allocator examples

This commit is contained in:
2026-07-12 00:39:39 +02:00
parent fbbbfa454c
commit cff9e9500f
7 changed files with 405 additions and 374 deletions
+6
View File
@@ -55,6 +55,12 @@ alloc func($T type, allocator Allocator, count usize) []mut T ! AllocError {
return .out_of_memory
}
free func($T type, allocator Allocator, memory []mut T) void {
if memory.len != 0 and size_of(T) != 0 {
raw_free(allocator, ptr_cast(u8, memory.ptr), memory.len * size_of(T), align_of(T))
}
}
_malloc_alignment usize :: 16 # ponytail: aarch64-macos libc malloc alignment assumption.
_power_of_two func(value usize) bool {