spot
0.8.1
|
A fixed-size memory pool implementation. More...
#include <misc/fixpool.hh>
Classes | |
struct | block_ |
union | chunk_ |
Public Member Functions | |
fixed_size_pool (size_t size) | |
Create a pool allocating objects of size bytes. | |
~fixed_size_pool () | |
Free any memory allocated by this pool. | |
void * | allocate () |
Allocate size bytes of memory. | |
void | deallocate (const void *ptr) |
Recycle size bytes of memory. | |
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_ |
A fixed-size memory pool implementation.
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.
void* spot::fixed_size_pool::allocate | ( | ) | [inline] |
Allocate size bytes of memory.
References chunklist_, spot::fixed_size_pool::chunk_::data_, free_end_, free_start_, freelist_, spot::fixed_size_pool::block_::next, spot::fixed_size_pool::chunk_::prev, and size_.
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.
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().