Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
BlockAllocator< T > Class Template Reference

#include <elm/alloc/BlockAllocator.h>

Public Member Functions

 BlockAllocator (int block_per_chunk=default_block_per_chunk)
 
T * allocate ()
 
void free (T *p)
 

Static Public Attributes

static const int default_block_per_chunk = 32
 

Detailed Description

template<class T>
class elm::BlockAllocator< T >

An allocator for fixed-size block. Initial allocation is performed quickly in a stack allocator but fried blocks are added to a free list allowing quick re-use of fried blocks.

Constructor & Destructor Documentation

◆ BlockAllocator()

BlockAllocator ( int  block_per_chunk = default_block_per_chunk)
inline

Block allocator builder.

Parameters
block_per_chunkNumber of block in each allocated chunk.
TType of managed blocks.

Member Function Documentation

◆ allocate()

T * allocate ( )
inline

Allocate an object.

Returns
Allocated object.

References StackAllocator::allocate().

◆ free()

void free ( T *  p)
inline

Free a previously allocated object.

Parameters
blockBlock to free.

References elm::io::p().

Member Data Documentation

◆ default_block_per_chunk

const int default_block_per_chunk = 32
static

The documentation for this class was generated from the following files: