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

@ -59,6 +59,36 @@ namespace xo {
return s.last_error_;
}
AllocInfo
IAllocator_DArena::alloc_info(DArena & s, value_type mem) noexcept
{
return s.alloc_info(mem);
if (!s.config_.store_header_flag_) [[unlikely]] {
++(s.error_count_);
s.last_error_ = AllocatorError(error::alloc_info_disabled,
s.error_count_,
0 /*add_commit_z*/,
s.committed_z_,
reserved(s));
return AllocInfo::error_not_configured(&s.config_.header_);
}
byte * header_mem = mem - sizeof(AllocHeader);
if (!s.contains(header_mem)) {
++(s.error_count_);
s.last_error_ = AllocatorError(error::alloc_info_address,
s.error_count_,
0 /*add_commit_z*/,
s.committed_z_,
reserved(s));
}
return AllocInfo(&s.config_.header_, (AllocHeader*)header_mem);
}
bool
IAllocator_DArena::expand(DArena & s, size_t target_z) noexcept
{