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

@ -5,7 +5,7 @@
#pragma once
#include "AllocatorError.hpp"
#include "AllocError.hpp"
#include "AllocInfo.hpp"
#include "xo/facet/facet_implementation.hpp"
#include "xo/facet/typeseq.hpp"
@ -74,7 +74,7 @@ namespace xo {
**/
virtual bool contains(Copaque d, const void * p) const noexcept = 0;
/** report last error **/
virtual AllocatorError last_error(Copaque d) const noexcept = 0;
virtual AllocError last_error(Copaque d) const noexcept = 0;
/** fetch alloc info: given memory @p mem previously obtained
* from {@ref alloc, @ref super_alloc}, get {tseq, age, size} details
* for that allocation.

View file

@ -1,4 +1,4 @@
/** @file AllocatorError.hpp
/** @file AllocError.hpp
*
* @author Roland Conybeare, Dec 2025
**/
@ -31,15 +31,15 @@ namespace xo {
alloc_info_address,
};
struct AllocatorError {
struct AllocError {
using size_type = std::size_t;
using value_type = std::byte*;
AllocatorError() = default;
explicit AllocatorError(error err,
AllocError() = default;
explicit AllocError(error err,
uint32_t seq) : error_{err},
error_seq_{seq} {}
AllocatorError(error err,
AllocError(error err,
uint32_t seq,
size_type req_z,
size_type com_z,
@ -66,4 +66,4 @@ namespace xo {
} /*namespace mm*/
} /*namespace xo*/
/* end AllocatorError.hpp */
/* end AllocError.hpp */

View file

@ -0,0 +1,44 @@
/** @file AllocInfo.hpp
*
* @author Roland Conybeare, Dec 2025
**/
#pragma once
#include "AllocHeader.hpp"
namespace xo {
namespace mm {
/** @class AllocInfo
* @brief bookkeeping information for an allocation
*
* AllocInfo instances are 1:1 with sum of calls to
* {@ref AAllocator::alloc, @ref AAllocator::alloc_super}
*
**/
struct AllocInfo {
using size_type = AllocHeader::size_type;
AllocInfo(const AllocHeaderConfig * p_cfg, const AllocHeader * p_hdr)
: p_config_{p_cfg}, p_header_{p_hdr} {}
/** error when alloc-header not configured **/
static AllocInfo error_not_configured(AllocHeaderConfig * p_cfg) { return AllocInfo(p_cfg, nullptr); }
/** true for non-sentinel AllocInfo instance **/
bool is_valid() const { return (p_config_ != nullptr) && (p_header_ != nullptr); }
/** Type sequence number in garbage collector **/
std::uint32_t tseq() const noexcept { return p_config_->tseq(*p_header_); }
/** Allocation age in garbage collector **/
std::uint32_t age() const noexcept { return p_config_->age (*p_header_); }
/** Allocation size (including allocator-supplied padding) **/
size_type size() const noexcept { return p_config_->size(*p_header_); }
const AllocHeaderConfig * p_config_ = nullptr;
const AllocHeader * p_header_ = nullptr;
};
} /*namespace mm*/
} /*namespace xo*/
/* end AllocInfo.hpp */

View file

@ -39,7 +39,7 @@ namespace xo {
[[noreturn]] size_type available(Copaque) const noexcept override { _fatal(); }
[[noreturn]] size_type allocated(Copaque) const noexcept override { _fatal(); }
[[noreturn]] bool contains(Copaque, const void *) const noexcept override { _fatal(); }
[[noreturn]] AllocatorError last_error(Copaque) const noexcept override { _fatal(); }
[[noreturn]] AllocError last_error(Copaque) const noexcept override { _fatal(); }
// non-const methods
[[noreturn]] AllocInfo alloc_info(Opaque, value_type) const noexcept override { _fatal(); }

View file

@ -38,7 +38,7 @@ namespace xo {
bool contains(Copaque d, const void * p) const noexcept override {
return I::contains(_dcast(d), p);
}
AllocatorError last_error(Copaque d) const noexcept override { return I::last_error(_dcast(d)); }
AllocError last_error(Copaque d) const noexcept override { return I::last_error(_dcast(d)); }
// non-const methods

View file

@ -33,7 +33,7 @@ namespace xo {
size_type available() const noexcept { return O::iface()->available(O::data()); }
size_type allocated() const noexcept { return O::iface()->allocated(O::data()); }
bool contains(const void * p) const noexcept { return O::iface()->contains(O::data(), p); }
AllocatorError last_error() const noexcept { return O::iface()->last_error(O::data()); }
AllocError last_error() const noexcept { return O::iface()->last_error(O::data()); }
value_type alloc(size_type z) noexcept { return O::iface()->alloc(O::data(), z); }
value_type super_alloc(size_type z) noexcept { return O::iface()->super_alloc(O::data(), z); }