xo-alloc2: + Allocator::alloc_info()
Also extend unit test
This commit is contained in:
parent
e369bc93f4
commit
ef8ec32a2d
15 changed files with 156 additions and 40 deletions
|
|
@ -247,6 +247,34 @@ namespace xo {
|
|||
return (header_type *)((byte *)obj - sizeof(header_type));
|
||||
}
|
||||
|
||||
AllocInfo
|
||||
DArena::alloc_info(value_type mem) noexcept
|
||||
{
|
||||
if (!config_.store_header_flag_) [[unlikely]] {
|
||||
++(error_count_);
|
||||
last_error_ = AllocatorError(error::alloc_info_disabled,
|
||||
error_count_,
|
||||
0 /*add_commit_z*/,
|
||||
committed_z_,
|
||||
this->reserved());
|
||||
|
||||
return AllocInfo::error_not_configured(&config_.header_);
|
||||
}
|
||||
|
||||
byte * header_mem = mem - sizeof(AllocHeader);
|
||||
|
||||
if (!this->contains(header_mem)) {
|
||||
++(error_count_);
|
||||
last_error_ = AllocatorError(error::alloc_info_address,
|
||||
error_count_,
|
||||
0 /*add_commit_z*/,
|
||||
committed_z_,
|
||||
this->reserved());
|
||||
}
|
||||
|
||||
return AllocInfo(&config_.header_, (AllocHeader *)header_mem);
|
||||
}
|
||||
|
||||
void
|
||||
DArena::clear() noexcept
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue