spot  0.8.2
Classes | Public Member Functions | Private Attributes | Static Private Attributes
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
[legend]

List of all members.

Classes

struct  block_
union  chunk_

Public Member Functions

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

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

Create a pool.

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 [static, private]

Referenced by fixsize().

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

Referenced by allocate().

Referenced by allocate().

Referenced by allocate(), and deallocate().


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

Please comment this page and report errors about it on the RefDocComments page.
Generated on Thu Jan 19 2012 19:33:04 for spot by doxygen 1.7.6.1