spot
1.0.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.
|
inline |
Create a pool allocating objects of size bytes.
References size_.
|
inline |
Free any memory allocated by this pool.
References chunklist_, and spot::fixed_size_pool::chunk_::prev.
|
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_.
|
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.
|
private |
Referenced by allocate(), and ~fixed_size_pool().
|
private |
Referenced by allocate().
|
private |
Referenced by allocate().
|
private |
Referenced by allocate(), and deallocate().
|
private |
Referenced by allocate(), and fixed_size_pool().