StackBufferAllocator< BLOCK_SIZE, LIFO, ALLOCATOR > Class Template Reference

#include <stackbufferallocator.h>

详细描述

template<Int BLOCK_SIZE, Bool LIFO, typename ALLOCATOR = DefaultAllocator>
class maxon::StackBufferAllocator< BLOCK_SIZE, LIFO, ALLOCATOR >

A StackBufferAllocator can be used if a large number of allocations shall be done in the sequel, and either all of those allocations will be freed together at a later point, or they will be freed in reverse order (LIFO). If all allocations will be freed together, set the LIFO template parameter to false, then there is practically no memory overhead for each allocation. For a de-allocation in reverse order, set LIFO to true. Then a structure of the size of two Ints has to be added for each allocation for bookkeeping purposes.

Template Parameters
BLOCK_SIZE Minimum size of each memory block which is obtained from ALLOCATOR.
LIFO Use true if you want to use this allocator in a stack-like LIFO way. This adds some overhead. If set to false, no actual de-allocation will happen until all allocations have been freed.
ALLOCATOR The parent allocator from which this allocator shall obtain its memory.

Classes

struct   Header

公共成员函数

  StackBufferAllocator ()
void *  Alloc ( Int size, MAXON_SOURCE_LOCATION_DECLARATION )
void  Free (const void *ptr)
  ~StackBufferAllocator ()

静态公共成员函数

static Bool   IsCompatibleWithDefaultAllocator (void *)

Private Attributes

ALLOCATOR  _allocator
BaseArray < Char * >  _memory
Header   _header
Char _end
Int   _allocCount

构造函数 & 析构函数文档编制

◆  StackBufferAllocator()

StackBufferAllocator ( )

◆  ~StackBufferAllocator()

~ StackBufferAllocator ( )

成员函数文档编制

◆  Alloc()

void* Alloc ( Int   size ,
MAXON_SOURCE_LOCATION_DECLARATION    
)

◆  Free()

void Free ( const void *  ptr )

◆  IsCompatibleWithDefaultAllocator()

static Bool IsCompatibleWithDefaultAllocator ( void *  )
static

Returns if a memory block allocated via this allocator can be reallocated or freed by the DefaultAllocator .

返回
Always false.

Member Data Documentation

◆  _allocator

ALLOCATOR _allocator private

◆  _memory

BaseArray < Char *> _memory
private

◆  _header

Header _header
private

◆  _end

Char * _end
private

◆  _allocCount

Int _allocCount
private