commit 75cf06c187d9d0288c2ea31f34b18c3a7da4bd1d (tree)
parent 41cdcd5486ba10dcd21dc45cb8470c556b7497dd
Author: Andrew Kelley <andrew@ziglang.org>
Date: Fri, 5 May 2023 13:26:01 -0700
std.mem.alignForwardGeneric: manually inline the assertions
This matches more directly the documentation comments, and makes it more
obvious what went wrong when an assertion fails.
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/std/mem.zig b/lib/std/mem.zig
@@ -4226,7 +4226,8 @@ pub fn alignForwardLog2(addr: usize, log2_alignment: u8) usize {
/// The alignment must be a power of 2 and greater than 0.
/// Asserts that rounding up the address does not cause integer overflow.
pub fn alignForwardGeneric(comptime T: type, addr: T, alignment: T) T {
- assert(isValidAlignGeneric(T, alignment));
+ assert(alignment > 0);
+ assert(std.math.isPowerOfTwo(alignment));
return alignBackwardGeneric(T, addr + (alignment - 1), alignment);
}