xo-alloc2: allocation unit tests
This commit is contained in:
parent
644100633d
commit
1ac6631d6d
4 changed files with 82 additions and 12 deletions
|
|
@ -30,6 +30,8 @@ namespace xo {
|
|||
size_type available() const { return O::iface()->available(O::data()); }
|
||||
size_type allocated() const { return O::iface()->allocated(O::data()); }
|
||||
bool contains(const void * p) const { return O::iface()->contains(O::data(), p); }
|
||||
AllocatorError last_error() const { return O::iface()->last_error(O::data()); }
|
||||
|
||||
bool expand(size_type z) { return O::iface()->expand(O::data(), z); }
|
||||
std::byte * alloc(size_type z) { return O::iface()->alloc(O::data(), z); }
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ namespace xo {
|
|||
/** word size for alignment**/
|
||||
static constexpr std::size_t c_alloc_alignment = sizeof(std::uintptr_t);
|
||||
|
||||
static inline std::size_t is_aligned(std::size_t n,
|
||||
std::size_t align = c_alloc_alignment) {
|
||||
return n % align == 0;
|
||||
}
|
||||
|
||||
/** how much to add to @p z to get a multiple of
|
||||
* @ref c_alloc_alignment
|
||||
**/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue