From 7cd7b6dfdbedf64dc4e2c6736b7c6ba3bd86ff07 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 16 Dec 2025 22:08:44 -0500 Subject: [PATCH] xo-alloc2: refactor: + AllocInfo.cpp --- .../include/xo/alloc2/alloc/AllocInfo.hpp | 18 ++-------- xo-alloc2/src/alloc2/AllocInfo.cpp | 34 +++++++++++++++++++ xo-alloc2/src/alloc2/CMakeLists.txt | 2 ++ 3 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 xo-alloc2/src/alloc2/AllocInfo.cpp diff --git a/xo-alloc2/include/xo/alloc2/alloc/AllocInfo.hpp b/xo-alloc2/include/xo/alloc2/alloc/AllocInfo.hpp index dbc742a2..eead62c7 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/AllocInfo.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/AllocInfo.hpp @@ -39,29 +39,15 @@ namespace xo { bool is_valid() const { return (p_config_ != nullptr) && (p_header_ != nullptr); } /** Guard bytes preceding allocation-header **/ - span_type guard_lo() const noexcept { - if (!p_guard_lo_) - return span_type(nullptr, nullptr); - - return span_type(p_guard_lo_, - p_guard_lo_ + p_config_->guard_z_); - } - + span_type guard_lo() const noexcept; /** 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_); } - /** Guard bytes immediately following allocation **/ - span_type guard_hi() const noexcept { - if (!p_guard_hi_) - return span_type(nullptr, nullptr); - - return span_type(p_guard_hi_, - p_guard_hi_ + p_config_->guard_z_); - } + span_type guard_hi() const noexcept; const AllocHeaderConfig * p_config_ = nullptr; const byte * p_guard_lo_ = nullptr; diff --git a/xo-alloc2/src/alloc2/AllocInfo.cpp b/xo-alloc2/src/alloc2/AllocInfo.cpp new file mode 100644 index 00000000..c0749ba9 --- /dev/null +++ b/xo-alloc2/src/alloc2/AllocInfo.cpp @@ -0,0 +1,34 @@ +/** @file AllocInfo.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "alloc/AllocInfo.hpp" + +namespace xo { + namespace mm { + + auto + AllocInfo::guard_lo() const noexcept -> span_type + { + if (!p_guard_lo_) + return span_type(nullptr, nullptr); + + return span_type(p_guard_lo_, + p_guard_lo_ + p_config_->guard_z_); + } + + auto + AllocInfo::guard_hi() const noexcept -> span_type + { + if (!p_guard_hi_) + return span_type(nullptr, nullptr); + + return span_type(p_guard_hi_, + p_guard_hi_ + p_config_->guard_z_); + } + + } /*namespace mm*/ +} /*namespace xo*/ + +/* end AllocInfo.cpp */ diff --git a/xo-alloc2/src/alloc2/CMakeLists.txt b/xo-alloc2/src/alloc2/CMakeLists.txt index dd111923..0e106895 100644 --- a/xo-alloc2/src/alloc2/CMakeLists.txt +++ b/xo-alloc2/src/alloc2/CMakeLists.txt @@ -3,6 +3,8 @@ set(SELF_LIB xo_alloc2) set(SELF_SRCS + AllocInfo.cpp + AAllocator.cpp DArena.cpp IAllocator_Any.cpp