spot  1.1.4
Classes | Public Member Functions | Private Attributes | List of all members
spot::fixed_size_pool Class Reference

A fixed-size memory pool implementation. More...

#include <misc/fixpool.hh>

Collaboration diagram for spot::fixed_size_pool:
Collaboration graph

Classes

struct  block_
 
union  chunk_
 

Public Member Functions

 fixed_size_pool (size_t size)
 Create a pool allocating objects of size bytes. More...
 
 ~fixed_size_pool ()
 Free any memory allocated by this pool. More...
 
void * allocate ()
 Allocate size bytes of memory. More...
 
void deallocate (const void *ptr)
 Recycle size bytes of memory. More...
 

Private Attributes

size_t size_
 
struct
spot::fixed_size_pool::block_
freelist_
 
char * free_start_
 
char * free_end_
 
union
spot::fixed_size_pool::chunk_
chunklist_
 

Detailed Description

A fixed-size memory pool implementation.

Constructor & Destructor Documentation

spot::fixed_size_pool::fixed_size_pool ( size_t  size)
inline

Create a pool allocating objects of size bytes.

References size_.

spot::fixed_size_pool::~fixed_size_pool ( )
inline

Free any memory allocated by this pool.

References chunklist_, and spot::fixed_size_pool::chunk_::prev.

Member Function Documentation

void* spot::fixed_size_pool::allocate ( )
inline
void spot::fixed_size_pool::deallocate ( const void *  ptr)
inline

Recycle size bytes of memory.

Despite the name, the memory is not really deallocated in the "delete" sense: it is still owned by the pool and will be reused by allocate as soon as possible. The memory is only freed when the pool is destroyed.

References freelist_, and spot::fixed_size_pool::block_::next.

Member Data Documentation

union spot::fixed_size_pool::chunk_* spot::fixed_size_pool::chunklist_
private

Referenced by allocate(), and ~fixed_size_pool().

char* spot::fixed_size_pool::free_end_
private

Referenced by allocate().

char* spot::fixed_size_pool::free_start_
private

Referenced by allocate().

struct spot::fixed_size_pool::block_* spot::fixed_size_pool::freelist_
private

Referenced by allocate(), and deallocate().

size_t spot::fixed_size_pool::size_
private

Referenced by allocate(), and fixed_size_pool().


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

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Mon Jul 29 2013 00:27:25 for spot by doxygen 1.8.4