63 void*
alloc(
size_t size);
242 const char*
p =
static_cast<const char*
>(
ptr);
267 for (;
it !=
p.second; ++
it)
void nameFactoryRegister(NameFactory< AbstractProduct > &factory)
Registers the string returned by ConcreteProduct::getStaticName() to a function that default-construc...
This is an arena allocator.
struct Arena::Block _block
void freeArrayAndAllAfter(T *array, T *arrayEnd)
As freeAndAllAfter(array) except that the elements of the array in the range (array,...
void freeAndAllAfterFromOldBlock(void *ptr)
As Arena::freeAndAllAfter where ptr was allocated from an old block.
static Arena _scratchArena
void * alloc(size_t size)
Returns a pointer to a buffer of size bytes.
void discardPreviousBlock()
Free the memory for the previous block.
bool isEmpty() const
Returns true if there are no live allocations for this Arena.
pair< T *, T * > allocArrayNoCon(size_t elementCount)
As alloc(elementCount * sizeof(T)).
void freeTop(void *ptr)
Frees the buffer pointed to by ptr.
void freeTopArray(T *array, T *arrayEnd)
As freeTop(array) except that the elements of the array in the range (array, arrayEnd] are deconstruc...
static size_t alignNoOverflow(size_t value)
Rounds value up to the nearest multiple of MemoryAlignment.
void freeTopFromOldBlock(void *ptr)
As Arena::freeTop where ptr was allocated from an old block.
void freeArrayAndAllAfter(pair< T *, T * > p)
As freeTopArrayAndAllAfter(p.first, p.second).
void freeTopArray(pair< T *, T * > p)
As freeTopArray(p.first, p.second).
void growCapacity(size_t needed)
Allocate a new block with at least needed bytes.
static Arena & getArena()
Returns an arena object that can be used for non-thread safe scratch memory after static objects have...
void freeAndAllAfter(void *ptr)
Frees the buffer pointed to by ptr and all not yet freed allocations that have happened since that bu...
pair< T *, T * > allocArray(size_t elementCount)
As allocArrayNoCon except that constructors for the elements of the array are called.
static const size_t MemoryAlignment
The alignment that memory allocators must ensure.
size_t getFreeCapacity() const
bool hasPreviousBlock() const
Block * _previousBlock
one past last byte (aligned)
char * _blockEnd
pointer to first free byte (aligned)
char * _freeBegin
beginning of current block (aligned)
bool isInBlock(const void *ptr) const