diff --git a/include/decodeless/allocator.hpp b/include/decodeless/allocator.hpp index 8352424..5a752a9 100644 --- a/include/decodeless/allocator.hpp +++ b/include/decodeless/allocator.hpp @@ -133,8 +133,8 @@ class linear_memory_resource { } [[nodiscard]] constexpr void* allocate(std::size_t bytes, std::size_t align) { - // Align - uintptr_t result = m_next + ((-static_cast(m_next)) & (align - 1)); + // Align, assumes 'align' is a power of two + uintptr_t result = (m_next + align - 1) & ~(align - 1); // Allocate uintptr_t newNext = result + bytes;