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

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

#include <misc/mspool.hh>

Collaboration diagram for spot::multiple_size_pool:
Collaboration graph

Classes

struct  block_
 
union  chunk_
 

Public Member Functions

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

Private Attributes

Sgi::hash_map< size_t, block_ * > freelist_
 
char * free_start_
 
char * free_end_
 
union
spot::multiple_size_pool::chunk_
chunklist_
 

Static Private Attributes

static const size_t alignment_ = 2 * sizeof(size_t) - 1
 

Detailed Description

A multiple-size memory pool implementation.

Constructor & Destructor Documentation

spot::multiple_size_pool::multiple_size_pool ( )
inline

Create a pool.

spot::multiple_size_pool::~multiple_size_pool ( )
inline

Free any memory allocated by this pool.

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

Member Function Documentation

void* spot::multiple_size_pool::allocate ( size_t  size)
inline
void spot::multiple_size_pool::deallocate ( const void *  ptr,
size_t  size 
)
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.

The size argument should be the same as the one passed to allocate().

References fixsize(), freelist_, and spot::multiple_size_pool::block_::next.

size_t spot::multiple_size_pool::fixsize ( size_t  size) const
inline

References alignment_.

Referenced by allocate(), and deallocate().

Member Data Documentation

const size_t spot::multiple_size_pool::alignment_ = 2 * sizeof(size_t) - 1
staticprivate

Referenced by fixsize().

union spot::multiple_size_pool::chunk_* spot::multiple_size_pool::chunklist_
private

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

char* spot::multiple_size_pool::free_end_
private

Referenced by allocate().

char* spot::multiple_size_pool::free_start_
private

Referenced by allocate().

Sgi::hash_map<size_t, block_*> spot::multiple_size_pool::freelist_
private

Referenced by allocate(), and deallocate().


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