[mem]: Fix handling of default resize to check alignment

This commit is contained in:
flysand7
2024-09-11 08:00:27 +11:00
parent fdd4882568
commit f16ed256ea
3 changed files with 19 additions and 5 deletions
+11
View File
@@ -456,6 +456,17 @@ is_power_of_two :: proc "contextless" (x: uintptr) -> bool {
return (x & (x-1)) == 0
}
/*
Check if a pointer is aligned.
This procedure checks whether a pointer `x` is aligned to a boundary specified
by `align`, and returns `true` if the pointer is aligned, and false otherwise.
*/
is_aligned :: proc "contextless" (x: rawptr, align: int) -> bool {
p := uintptr(x)
return (p & (1<<uintptr(align) - 1)) == 0
}
/*
Align uintptr forward.