diff --git a/ircd/allocator.cc b/ircd/allocator.cc index f8b1b84b4..9115a5b3c 100644 --- a/ircd/allocator.cc +++ b/ircd/allocator.cc @@ -475,18 +475,27 @@ ircd::allocator::operator+=(profile &a, // std::unique_ptr -ircd::allocator::aligned_alloc(const size_t &align, - const size_t &size) +ircd::allocator::aligned_alloc(const size_t &alignment_, + const size_t &size_) { - static const size_t &align_default{16}; - const size_t &alignment + static const size_t &align_default { - align?: align_default + 16 + }; + + const size_t &alignment + { + alignment_?: align_default + }; + + const size_t &size + { + size_ % alignment == 0? size_: size_ + (alignment - (size_ % alignment)) }; - assert(alignment % 2UL == 0); - assert(alignment % sizeof(void *) == 0); assert(size % alignment == 0); + assert(size < size_ + alignment); + assert(alignment % sizeof(void *) == 0); void *ret; switch(int errc(::posix_memalign(&ret, alignment, size)); errc)