Class SizeClassAllocator

Nested Relationships

Nested Types

Class Documentation

class SizeClassAllocator

an allocator of small blocks by size classes, for one thread

Public Functions

SizeClassAllocator(void) = default
SizeClassAllocator(const SizeClassAllocator&) = delete
SizeClassAllocator &operator=(const SizeClassAllocator&) = delete
SizeClassAllocator(SizeClassAllocator &&other) noexcept

the pages of other, which is left empty

SizeClassAllocator &operator=(SizeClassAllocator &&other) noexcept
inline ~SizeClassAllocator()

frees the pages

void *allocate(std::size_t n)

a block of n bytes at least, aligned to 16 bytes (to the power of 2 that divides its class, 8 for the class of 8 bytes)

Pre:

n >= 1

void deallocate(void *p, std::size_t n) noexcept

gives back the block p of a request of n bytes

Pre:

p was given by allocate( n ) of this allocator

inline std::size_t bytes(void) const

the memory of the pages, in bytes

void release(void) noexcept

frees all the pages; the blocks given are no longer valid

Public Static Functions

static unsigned sizeClass(std::size_t n)

the class of a request of n bytes, and its size

static std::size_t classSize(unsigned c)

Public Static Attributes

static constexpr std::size_t LARGEST = 32768

the largest request served by the classes

static constexpr std::size_t PAGE = std::size_t(1) << 16

the bytes of a page