xo-alloc2: refactor - explicit AllocHeader class

This commit is contained in:
Roland Conybeare 2025-12-16 11:43:41 -05:00
commit e369bc93f4
10 changed files with 251 additions and 37 deletions

View file

@ -5,6 +5,7 @@
#pragma once
#include "alloc/AllocHeader.hpp"
#include "alloc/AllocatorError.hpp"
#include <string>
#include <cstdint>
@ -47,9 +48,13 @@ namespace xo {
* present in arena
**/
bool store_header_flag_ = false;
#ifdef OBSOLETE
/** number of bits to represent allocation size **/
std::uint64_t header_size_bits_ = 32;
std::uint64_t header_size_mask_ = (1ul << header_size_bits_) - 1;
#endif
/** configuration for per-alloc header **/
AllocHeaderConfig header_;
/** true to enable debug logging **/
bool debug_flag_ = false;

View file

@ -10,17 +10,6 @@
namespace xo {
namespace mm {
/** **/
struct AllocHeader {
using repr_type = std::uint64_t;
explicit AllocHeader(repr_type x) : repr_{x} {}
repr_type repr_;
};
static_assert(sizeof(AllocHeader) == sizeof(AllocHeader::repr_type));
/** @class DArena
*
* @brief represent arena allocator state
@ -51,7 +40,7 @@ namespace xo {
/** @brief a contiguous memory range **/
using range_type = std::pair<value_type, value_type>;
/** @brief type for allocation header (if enabled) **/
using header_type = std::uint64_t;
using header_type = AllocHeader; //std::uint64_t;
///@}