10#if !defined(ALIB_MONOMEM_POOLALLOCATOR_DEFAULT_ALIGNMENT)
11# define ALIB_MONOMEM_POOLALLOCATOR_DEFAULT_ALIGNMENT alignof(uint64_t)
83template<
typename TAllocator,
size_t TAlignment= ALIB_MONOMEM_POOLALLOCATOR_DEFAULT_ALIGNMENT>
85#if ALIB_DEBUG_CRITICAL_SECTIONS
89 static_assert( TAlignment >=
alignof(
void*),
90 "The (fixed) alignment of the pool allocator has to be at least as high as alignof(void*). "
91 "Adjust template parameter TAlignment." );
93 static_assert( TAlignment <= TAllocator::MAX_ALIGNMENT,
94 "The (fixed) alignment of the pool allocator cannot be greater than the MAX_ALIGNMENT of "
95 "its chained allocator. Adjust template parameter TAlignment." );
99 "The fixed alignment of the pool allocator is not a power of 2. "
100 "Adjust template parameter TAlignment." );
106 static constexpr unsigned char MAGIC= 0xA3;
110 static constexpr unsigned char CLEAR= 0xF3;
133 #if ALIB_DEBUG_MEMORY
138 #if ALIB_DEBUG_ALLOCATIONS
169 if( requestedObjectSize <
sizeof(
void*) )
180 template<
size_t TRequestedObjectSize>
184 if( TRequestedObjectSize <
sizeof(
void*) )
186 constexpr int msb =
lang::MSB(TRequestedObjectSize);
218 template<
typename TRequires= allocMember>
219 requires std::default_initializable<TRequires>
221 #if ALIB_DEBUG_CRITICAL_SECTIONS
227 "The fixed alignment {} of the pool allocator is not a power of 2. "
228 "Adjust template parameter TAlignment.", TAlignment )
236 #if ALIB_DEBUG_ALLOCATIONS
240 #if ALIB_DEBUG_MEMORY
268 "The requested alignment is higher than what was specified with "
269 "template parameter TAlignment: {} >= {}", pAlignment, TAlignment )
272 #if ALIB_DEBUG_ALLOCATIONS
293 void*
reallocate(
void* mem,
size_t oldSize,
size_t& newSize,
size_t pAlignment );
300 void free(
void* mem,
size_t size)
302 #if ALIB_DEBUG_ALLOCATIONS
312 template<
typename TSize>
380 template<
typename TIntegral>
381 requires std::integral<TIntegral>
414 #if ALIB_DEBUG_ALLOCATIONS
425 *
reinterpret_cast<void**
>(mem)=
hooks[allocInfo];
426 hooks[allocInfo]= mem;
435 #if ALIB_DEBUG_ALLOCATIONS
438 #if ALIB_DEBUG_MEMORY
459 template<
typename TSize>
463 #if ALIB_DEBUG_ALLOCATIONS
505 #if ALIB_DEBUG_MEMORY
void FreeByAllocationInfo(int allocInfo, void *mem)
TAllocator ChainedAllocator
static constexpr short qtyHooks()
uinteger DbgStatAllocCounter(size_t size)
int DbgCountedOpenAllocations()
static constexpr size_t MIN_ALIGNMENT
void dbgAcknowledgeIncreasedAllocSize(void *mem, TSize allocSize) const
void dbgCheckMemory(void *mem, TSize size)
static constexpr size_t GetAllocationSize(short allocInfo)
void deletePool()
Frees all recycled pool objects.
static constexpr short hookIndex()
uinteger * dbgStatAllocCounter
static constexpr size_t MAX_ALIGNMENT
size_t dbgLastRequestedSize
static constexpr int AllocationInformationBitCount()
int DbgCountedOpenAllocations(size_t size)
void * allocate(size_t &size, size_t pAlignment)
static constexpr unsigned char CLEAR
lang::AllocatorMember< TAllocator > allocMember
A shortcut to a base type.
constexpr bool allowsMemSplit() noexcept
static constexpr short hookIndex(size_t requestedObjectSize)
static constexpr short GetAllocInformation(TIntegral size)
static constexpr unsigned char MAGIC
ALIB_DLL TPoolAllocator(TAllocator &pAllocator)
void * reallocate(void *mem, size_t oldSize, size_t &newSize, size_t pAlignment)
void free(void *mem, size_t size)
int DbgSuppressNonFreedObjectsWarning()
uinteger DbgStatAllocCounter()
ALIB_DLL void * AllocateByAllocationInfo(int allocInfo)
lang::AllocatorInterface< TPoolAllocator > operator()()
static constexpr short minimumHookIndex()
ALIB_DLL integer GetPoolSize(size_t size)
ALIB_DLL ~TPoolAllocator()
Destructs this type.
static constexpr short GetAllocInformation()
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_REL_DBG(releaseCode,...)
constexpr int MSB(TIntegral value)
constexpr TIntegral LowerMask()
constexpr int BitCount(TIntegral value)
lang::integer integer
Type alias in namespace alib.
monomem::TPoolAllocator< MonoAllocator > PoolAllocator
lang::StdContainerAllocator< T, PoolAllocator > SCAPool
monomem::TPoolAllocator< lang::HeapAllocator > PoolAllocatorHA
lang::uinteger uinteger
Type alias in namespace alib.
AllocatorInterface< TAllocator > AI() const noexcept
MonoAllocator & GetAllocator() const noexcept
static constexpr void clearMem(T *mem, size_t size, unsigned char magic)
static constexpr void annotate(T *mem, size_t size, unsigned char magic)
static void checkMem(void *mem, const TSize size, unsigned char magic, const char *name)