diff --git a/src/allocator.rs b/src/allocator.rs
index 9ce4a887..11ebeb52 100644
--- a/src/allocator.rs
+++ b/src/allocator.rs
@@ -74,11 +74,9 @@ impl Locked {
}
}
+/// Align the given address `addr` upwards to alignment `align`.
+///
+/// Requires that `align` is a power of two.
fn align_up(addr: usize, align: usize) -> usize {
- let remainder = addr % align;
- if remainder == 0 {
- addr // addr already aligned
- } else {
- addr - remainder + align
- }
+ (addr + align - 1) & !(align - 1)
}