Dep/short_alloc: Allow any alignment
Signed-off-by: luis <[email protected]>
This commit is contained in:
@@ -77,10 +77,7 @@ arena<N, alignment>::allocate(std::size_t n)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static_assert(alignment <= alignof(std::max_align_t), "you've chosen an "
|
return static_cast<char*>(::operator new(n, std::align_val_t(alignment)));
|
||||||
"alignment that is larger than alignof(std::max_align_t), and "
|
|
||||||
"cannot be guaranteed by normal operator new");
|
|
||||||
return static_cast<char*>(::operator new(n));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t N, std::size_t alignment>
|
template <std::size_t N, std::size_t alignment>
|
||||||
@@ -95,7 +92,7 @@ arena<N, alignment>::deallocate(char* p, std::size_t n) noexcept
|
|||||||
ptr_ = p;
|
ptr_ = p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
::operator delete(p);
|
::operator delete(p, std::align_val_t(alignment));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, std::size_t N, std::size_t Align = alignof(std::max_align_t)>
|
template <class T, std::size_t N, std::size_t Align = alignof(std::max_align_t)>
|
||||||
|
|||||||
Reference in New Issue
Block a user