bm::mem_alloc< BA, PA > Class Template Reference
[Memory Allocation]

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_talloc_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_talloc_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.

Detailed Description

template<class BA, class PA>
class bm::mem_alloc< BA, PA >

BM style allocator adapter.

Template takes two parameters BA - allocator object for bit blocks and PA - allocator object for pointer blocks.

Examples:

sample6.cpp.

Definition at line 139 of file bmalloc.h.


Member Typedef Documentation

template<class BA , class PA >
typedef BA bm::mem_alloc< BA, PA >::block_allocator_type

Definition at line 142 of file bmalloc.h.

template<class BA , class PA >
typedef PA bm::mem_alloc< BA, PA >::ptr_allocator_type

Definition at line 143 of file bmalloc.h.


Constructor & Destructor Documentation

template<class BA , class PA >
bm::mem_alloc< BA, PA >::mem_alloc ( const BA &  block_alloc = BA(),
const PA &  ptr_alloc = PA() 
) [inline]

Definition at line 147 of file bmalloc.h.


Member Function Documentation

template<class BA , class PA >
bm::word_t* bm::mem_alloc< BA, PA >::alloc_bit_block ( unsigned  alloc_factor = 1  )  [inline]

Allocates and returns bit block.

Parameters:
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.

template<class BA , class PA >
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<>.

Parameters:
level GAP block level.

Definition at line 193 of file bmalloc.h.

References BM_ASSERT, and bm::gap_levels.

template<class BA , class PA >
void* bm::mem_alloc< BA, PA >::alloc_ptr ( unsigned  size = bm::set_array_size  )  [inline]

Allocates block of pointers.

Definition at line 217 of file bmalloc.h.

template<class BA , class PA >
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.

template<class BA , class PA >
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.

template<class BA , class PA >
void bm::mem_alloc< BA, PA >::free_ptr ( void *  p,
unsigned  size = bm::set_array_size 
) [inline]

Frees block of pointers.

Definition at line 224 of file bmalloc.h.

template<class BA , class PA >
block_allocator_type bm::mem_alloc< BA, PA >::get_block_allocator (  )  const [inline]

Returns copy of the block allocator object.

Definition at line 154 of file bmalloc.h.

template<class BA , class PA >
ptr_allocator_type bm::mem_alloc< BA, PA >::get_ptr_allocator (  )  const [inline]

Returns copy of the ptr allocator object.

Definition at line 161 of file bmalloc.h.


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

Generated on Sun Apr 25 09:37:46 2010 for BitMagic by  doxygen 1.6.1