xo-alloc2: rename: AllocatorError -> AllocError

This commit is contained in:
Roland Conybeare 2025-12-16 17:18:38 -05:00
commit 2dec6dbee8
16 changed files with 113 additions and 69 deletions

View file

@ -189,7 +189,7 @@ namespace xo {
other.limit_ = nullptr;
other.hi_ = nullptr;
other.error_count_ = 0;
other.last_error_ = AllocatorError();
other.last_error_ = AllocError();
}
DArena &
@ -212,7 +212,7 @@ namespace xo {
other.limit_ = nullptr;
other.hi_ = nullptr;
other.error_count_ = 0;
other.last_error_ = AllocatorError();
other.last_error_ = AllocError();
return *this;
}
@ -236,7 +236,7 @@ namespace xo {
limit_ = nullptr;
hi_ = nullptr;
error_count_ = 0;
last_error_ = AllocatorError();
last_error_ = AllocError();
}
DArena::header_type *
@ -252,11 +252,11 @@ namespace xo {
{
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());
last_error_ = AllocError(error::alloc_info_disabled,
error_count_,
0 /*add_commit_z*/,
committed_z_,
this->reserved());
return AllocInfo::error_not_configured(&config_.header_);
}
@ -265,11 +265,11 @@ namespace xo {
if (!this->contains(header_mem)) {
++(error_count_);
last_error_ = AllocatorError(error::alloc_info_address,
error_count_,
0 /*add_commit_z*/,
committed_z_,
this->reserved());
last_error_ = AllocError(error::alloc_info_address,
error_count_,
0 /*add_commit_z*/,
committed_z_,
this->reserved());
}
return AllocInfo(&config_.header_, (AllocHeader *)header_mem);

View file

@ -120,7 +120,7 @@ namespace xo {
return false;
}
AllocatorError
AllocError
DX1Collector::last_error() const noexcept
{
// TODO:

View file

@ -54,7 +54,7 @@ namespace xo {
return (s.lo_ <= p) && (p < s.hi_);
}
AllocatorError
AllocError
IAllocator_DArena::last_error(const DArena & s) noexcept {
return s.last_error_;
}
@ -66,11 +66,11 @@ namespace xo {
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));
s.last_error_ = AllocError(error::alloc_info_disabled,
s.error_count_,
0 /*add_commit_z*/,
s.committed_z_,
reserved(s));
return AllocInfo::error_not_configured(&s.config_.header_);
}
@ -79,11 +79,11 @@ namespace xo {
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));
s.last_error_ = AllocError(error::alloc_info_address,
s.error_count_,
0 /*add_commit_z*/,
s.committed_z_,
reserved(s));
}
return AllocInfo(&s.config_.header_, (AllocHeader*)header_mem);
@ -105,9 +105,9 @@ namespace xo {
if (s.lo_ + target_z > s.hi_) [[unlikely]] {
++(s.error_count_);
s.last_error_ = AllocatorError(error::reserve_exhausted,
s.error_count_,
target_z, s.committed_z_, reserved(s));
s.last_error_ = AllocError(error::reserve_exhausted,
s.error_count_,
target_z, s.committed_z_, reserved(s));
return false;
}
@ -137,35 +137,35 @@ namespace xo {
assert(s.limit_ == s.lo_ + s.committed_z_);
// log && log(xtag("aligned_offset_z", aligned_offset_z),
// xtag("add_commit_z", add_commit_z));
// log && log("expand committed range",
// xtag("commit_start", commit_start),
// xtag("add_commit_z", add_commit_z),
// xtag("commit_end", commit_start + add_commit_z));
// log && log(xtag("aligned_offset_z", aligned_offset_z),
// xtag("add_commit_z", add_commit_z));
// log && log("expand committed range",
// xtag("commit_start", commit_start),
// xtag("add_commit_z", add_commit_z),
// xtag("commit_end", commit_start + add_commit_z));
if (::mprotect(commit_start,
add_commit_z,
PROT_READ | PROT_WRITE) != 0) [[unlikely]]
{
++(s.error_count_);
s.last_error_ = AllocatorError(error::commit_failed,
s.error_count_,
add_commit_z, s.committed_z_, reserved(s));
{
++(s.error_count_);
s.last_error_ = AllocError(error::commit_failed,
s.error_count_,
add_commit_z, s.committed_z_, reserved(s));
#ifdef OBSOLETE
throw std::runtime_error(tostr("ArenaAlloc::expand: commit failure",
xtag("committed_z", s.committed_z_),
xtag("add_commit_z", add_commit_z)));
throw std::runtime_error(tostr("ArenaAlloc::expand: commit failure",
xtag("committed_z", s.committed_z_),
xtag("add_commit_z", add_commit_z)));
#endif
return false;
}
return false;
}
s.committed_z_ = aligned_target_z;
s.limit_ = s.lo_ + s.committed_z_;
if (commit_start == s.lo_) [[unlikely]]
{
/* first expand() for this allocator - start with guard_z_ bytes */
{
/* first expand() for this allocator - start with guard_z_ bytes */
::memset(s.free_,
s.config_.guard_byte_,
@ -230,7 +230,7 @@ namespace xo {
if (s.config_.store_header_flag_) {
if (!s.last_header_) [[unlikely]] {
++(s.error_count_);
s.last_error_ = AllocatorError(error::orphan_sub_alloc,
s.last_error_ = AllocError(error::orphan_sub_alloc,
s.error_count_,
0 /*add_commit_z*/, s.committed_z_, reserved(s));
} else {
@ -261,7 +261,7 @@ namespace xo {
if (s.config_.store_header_flag_) {
if (!s.last_header_) [[unlikely]] {
++(s.error_count_);
s.last_error_ = AllocatorError(error::orphan_sub_alloc,
s.last_error_ = AllocError(error::orphan_sub_alloc,
s.error_count_,
0 /*add_commit_z*/, s.committed_z_, reserved(s));
return nullptr;
@ -277,7 +277,7 @@ namespace xo {
if ((header & s.config_.header_size_mask_ & z0) != z0) [[unlikely]] {
/* cumulative alloc size doesn't fit in configured header_size_mask bits */
++(s.error_count_);
s.last_error_ = AllocatorError(error::header_size_mask,
s.last_error_ = AllocError(error::header_size_mask,
s.error_count_,
0 /*add_commit_z*/, s.committed_z_, reserved(s));
return nullptr;
@ -366,7 +366,7 @@ namespace xo {
} else {
/* req_z doesn't fit in configured header_size_mask bits */
++(s.error_count_);
s.last_error_ = AllocatorError(error::header_size_mask,
s.last_error_ = AllocError(error::header_size_mask,
s.error_count_,
0 /*add_commit_z*/,
s.committed_z_,

View file

@ -55,7 +55,7 @@ namespace xo {
return d.contains(role::to_space(), addr);
}
AllocatorError
AllocError
IAllocator_DX1Collector::last_error(const DX1Collector & d) noexcept
{
return d.last_error();