xo-alloc2: + Allocator::alloc_info()

Also extend unit test
This commit is contained in:
Roland Conybeare 2025-12-16 16:44:44 -05:00
commit ef8ec32a2d
15 changed files with 156 additions and 40 deletions

View file

@ -88,6 +88,18 @@ namespace xo {
/** get header from allocated object address **/
header_type * obj2hdr(void * obj) noexcept;
/** report alloc book-keeping info for allocation at @p mem
*
* Require:
* 1. @p mem is address returned by allocation on this arena
* i.e. by @ref IAllocator_DArena::alloc() or @ref IAllocator_DArena::alloc_super()
* 2. @p mem has not been invalidated since it was allocated
* i.e. by call to @ref DArena::clear
*
* Note: non-const, may stash error details
**/
AllocInfo alloc_info(value_type mem) noexcept;
/** discard all allocated memory, return to empty state
* Promise:
* - committed memory unchanged

View file

@ -45,6 +45,8 @@ namespace xo {
static bool contains(const DArena &, const void * p) noexcept;
static AllocatorError last_error(const DArena &) noexcept;
/** retrieve allocation bookkeeping info for @p mem from arena @p d **/
static AllocInfo alloc_info(DArena &, value_type mem) noexcept;
/** expand committed space in arena @p d
* to size at least @p z
* In practice will round up to a multiple of @ref page_z_.