BM style allocator adapter. More...
#include <bmalloc.h>
Public Types | |
typedef BA | block_allocator_type |
typedef PA | ptr_allocator_type |
Public Member Functions | |
mem_alloc (const BA &block_alloc=BA(), const PA &ptr_alloc=PA()) | |
block_allocator_type | get_block_allocator () const |
Returns copy of the block allocator object. | |
ptr_allocator_type | get_ptr_allocator () const |
Returns copy of the ptr allocator object. | |
bm::word_t * | alloc_bit_block (unsigned alloc_factor=1) |
Allocates and returns bit block. | |
void | free_bit_block (bm::word_t *block, unsigned alloc_factor=1) |
Frees bit block allocated by alloc_bit_block. | |
bm::gap_word_t * | alloc_gap_block (unsigned level, const gap_word_t *glevel_len) |
Allocates GAP block using bit block allocator (BA). | |
void | free_gap_block (bm::gap_word_t *block, const gap_word_t *glevel_len) |
Frees GAP block using bot block allocator (BA). | |
void * | alloc_ptr (unsigned size=bm::set_array_size) |
Allocates block of pointers. | |
void | free_ptr (void *p, unsigned size=bm::set_array_size) |
Frees block of pointers. |
BM style allocator adapter.
Template takes two parameters BA - allocator object for bit blocks and PA - allocator object for pointer blocks.
Definition at line 139 of file bmalloc.h.
typedef BA bm::mem_alloc< BA, PA >::block_allocator_type |
typedef PA bm::mem_alloc< BA, PA >::ptr_allocator_type |
bm::mem_alloc< BA, PA >::mem_alloc | ( | const BA & | block_alloc = BA() , |
|
const PA & | ptr_alloc = PA() | |||
) | [inline] |
bm::word_t* bm::mem_alloc< BA, PA >::alloc_bit_block | ( | unsigned | alloc_factor = 1 |
) | [inline] |
Allocates and returns bit block.
alloc_factor | indicated how many blocks we want to allocate in chunk total allocation is going to be bm::set_block_size * alloc_factor Default allocation factor is 1 |
Definition at line 173 of file bmalloc.h.
References bm::set_block_size.
bm::gap_word_t* bm::mem_alloc< BA, PA >::alloc_gap_block | ( | unsigned | level, | |
const gap_word_t * | glevel_len | |||
) | [inline] |
Allocates GAP block using bit block allocator (BA).
GAP blocks in BM library belong to levels. Each level has a correspondent length described in bm::gap_len_table<>.
level | GAP block level. |
Definition at line 193 of file bmalloc.h.
References BM_ASSERT, and bm::gap_levels.
void* bm::mem_alloc< BA, PA >::alloc_ptr | ( | unsigned | size = bm::set_array_size |
) | [inline] |
void bm::mem_alloc< BA, PA >::free_bit_block | ( | bm::word_t * | block, | |
unsigned | alloc_factor = 1 | |||
) | [inline] |
Frees bit block allocated by alloc_bit_block.
Definition at line 180 of file bmalloc.h.
References IS_VALID_ADDR, and bm::set_block_size.
void bm::mem_alloc< BA, PA >::free_gap_block | ( | bm::gap_word_t * | block, | |
const gap_word_t * | glevel_len | |||
) | [inline] |
Frees GAP block using bot block allocator (BA).
Definition at line 205 of file bmalloc.h.
References BM_ASSERT, bm::gap_capacity(), and IS_VALID_ADDR.
void bm::mem_alloc< BA, PA >::free_ptr | ( | void * | p, | |
unsigned | size = bm::set_array_size | |||
) | [inline] |
block_allocator_type bm::mem_alloc< BA, PA >::get_block_allocator | ( | ) | const [inline] |
ptr_allocator_type bm::mem_alloc< BA, PA >::get_ptr_allocator | ( | ) | const [inline] |