59#ifndef __ADS_SizeClassAllocator
60 #define __ADS_SizeClassAllocator
93 static constexpr std::size_t
LARGEST = 32768;
96 static constexpr std::size_t
PAGE = std::size_t( 1 ) << 16;
169 [[nodiscard]]
static unsigned sizeClass( std::size_t n );
175 [[nodiscard]]
static std::size_t
classSize(
unsigned c );
178 [[nodiscard]] std::size_t
bytes(
void )
const {
return( f_bytes ); }
186 static constexpr unsigned CLASSES = 9 + 4 * 8;
205 void * fresh(
unsigned c );
207 Free * f_free[ CLASSES ] = {};
208 char * f_next[ CLASSES ] = {};
209 char * f_end[ CLASSES ] = {};
210 Page * f_pages =
nullptr;
211 std::size_t f_bytes = 0;
223#include "ADS/memory/impl/SizeClassAllocator.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
void release(void) noexcept
frees all the pages; the blocks given are no longer valid
SizeClassAllocator & operator=(const SizeClassAllocator &)=delete
no copy, since its blocks are in its pages
static unsigned sizeClass(std::size_t n)
the class of a request of bytes: 0 for , up to 128, and otherwise, with ,
~SizeClassAllocator()
frees the pages
Definition SizeClassAllocator.h:113
static std::size_t classSize(unsigned c)
the size of the class : 8, up to 128, and otherwise with and
SizeClassAllocator & operator=(SizeClassAllocator &&other) noexcept
the pages of other, which is left empty, after those of this allocator are freed
SizeClassAllocator(void)=default
the allocator with no page
static constexpr std::size_t PAGE
the bytes of a page
Definition SizeClassAllocator.h:96
SizeClassAllocator(const SizeClassAllocator &)=delete
no copy, since its blocks are in its pages
SizeClassAllocator(SizeClassAllocator &&other) noexcept
the pages of other, which is left empty
void * allocate(std::size_t n)
a block of bytes at least, aligned to 16 bytes (8 for the class of 8 bytes)
std::size_t bytes(void) const
the memory of the pages, in bytes
Definition SizeClassAllocator.h:178
void deallocate(void *p, std::size_t n) noexcept
gives back the block of a request of bytes, pushed on for its class
static constexpr std::size_t LARGEST
the largest request served by the classes
Definition SizeClassAllocator.h:93