BitMagic-C++
Public Types | Public Member Functions | Protected Attributes
bm::mem_alloc< BA, PA, APool > Class Template Reference

BM style allocator adapter. More...

#include <bmalloc.h>

Public Types

typedef BA block_allocator_type
 
typedef PA ptr_allocator_type
 
typedef APool allocator_pool_type
 

Public Member Functions

 mem_alloc (const BA &block_alloc=BA(), const PA &ptr_alloc=PA()) BMNOEXCEPT
 
 mem_alloc (const mem_alloc &ma) BMNOEXCEPT
 
mem_allocoperator= (const mem_alloc &ma) BMNOEXCEPT
  More...
 
block_allocator_type get_block_allocator () const BMNOEXCEPT
 Returns copy of the block allocator object. More...
 
ptr_allocator_type get_ptr_allocator () const BMNOEXCEPT
 Returns copy of the ptr allocator object. More...
 
void set_pool (allocator_pool_type *pool) BMNOEXCEPT
 set pointer to external pool More...
 
allocator_pool_typeget_pool () BMNOEXCEPT
 get pointer to allocation pool (if set) More...
 
bm::word_talloc_bit_block (unsigned alloc_factor=1)
 Allocates and returns bit block. More...
 
void free_bit_block (bm::word_t *block, size_t alloc_factor=1) BMNOEXCEPT
 Frees bit block allocated by alloc_bit_block. More...
 
bm::gap_word_talloc_gap_block (unsigned level, const bm::gap_word_t *glevel_len)
 Allocates GAP block using bit block allocator (BA). More...
 
void free_gap_block (bm::gap_word_t *block, const bm::gap_word_t *glevel_len)
 Frees GAP block using bot block allocator (BA) More...
 
void * alloc_ptr (size_t size)
 Allocates block of pointers. More...
 
void free_ptr (void *p, size_t size) BMNOEXCEPT
 Frees block of pointers. More...
 
BA & get_block_alloc () BMNOEXCEPT
 Get access to block allocator. More...
 

Protected Attributes

BA block_alloc_
  More...
 
PA ptr_alloc_
  More...
 
allocator_pool_typealloc_pool_p_
  More...
 

Detailed Description

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

BM style allocator adapter.

Template takes parameters: BA - allocator object for bit blocks PA - allocator object for pointer blocks APool - Allocation pool

Examples
sample6.cpp.

Definition at line 290 of file bmalloc.h.

Member Function Documentation

◆ alloc_bit_block()

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

Allocates and returns bit block.

Parameters
alloc_factorindicated 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 352 of file bmalloc.h.

References bm::mem_alloc< BA, PA, APool >::alloc_pool_p_, bm::mem_alloc< BA, PA, APool >::block_alloc_, and bm::set_block_size.

◆ alloc_gap_block()

template<class BA , class PA , class APool >
bm::gap_word_t* bm::mem_alloc< BA, PA, APool >::alloc_gap_block ( unsigned  level,
const bm::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
levelGAP block level.
glevel_lentable of level lengths

Definition at line 378 of file bmalloc.h.

References bm::mem_alloc< BA, PA, APool >::block_alloc_, BM_ASSERT, and bm::gap_levels.

◆ alloc_ptr()

template<class BA , class PA , class APool >
void* bm::mem_alloc< BA, PA, APool >::alloc_ptr ( size_t  size)
inline

Allocates block of pointers.

Definition at line 402 of file bmalloc.h.

References BM_ASSERT, and bm::mem_alloc< BA, PA, APool >::ptr_alloc_.

◆ free_bit_block()

template<class BA , class PA , class APool >
void bm::mem_alloc< BA, PA, APool >::free_bit_block ( bm::word_t block,
size_t  alloc_factor = 1 
)
inline

Frees bit block allocated by alloc_bit_block.

Definition at line 361 of file bmalloc.h.

References bm::mem_alloc< BA, PA, APool >::alloc_pool_p_, bm::mem_alloc< BA, PA, APool >::block_alloc_, BM_ASSERT, IS_VALID_ADDR, and bm::set_block_size.

◆ free_gap_block()

template<class BA , class PA , class APool >
void bm::mem_alloc< BA, PA, APool >::free_gap_block ( bm::gap_word_t block,
const bm::gap_word_t glevel_len 
)
inline

Frees GAP block using bot block allocator (BA)

Definition at line 390 of file bmalloc.h.

References bm::mem_alloc< BA, PA, APool >::block_alloc_, BM_ASSERT, bm::gap_capacity(), and IS_VALID_ADDR.

◆ free_ptr()

template<class BA , class PA , class APool >
void bm::mem_alloc< BA, PA, APool >::free_ptr ( void *  p,
size_t  size 
)
inline

Frees block of pointers.

Definition at line 410 of file bmalloc.h.

References bm::mem_alloc< BA, PA, APool >::ptr_alloc_.

◆ get_block_alloc()

template<class BA , class PA , class APool >
BA& bm::mem_alloc< BA, PA, APool >::get_block_alloc ( )
inline

Get access to block allocator.

Definition at line 419 of file bmalloc.h.

References bm::mem_alloc< BA, PA, APool >::block_alloc_.

◆ get_block_allocator()

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

Returns copy of the block allocator object.

Definition at line 322 of file bmalloc.h.

References bm::mem_alloc< BA, PA, APool >::block_alloc_.

◆ get_pool()

template<class BA , class PA , class APool >
allocator_pool_type* bm::mem_alloc< BA, PA, APool >::get_pool ( )
inline

get pointer to allocation pool (if set)

Definition at line 341 of file bmalloc.h.

References bm::mem_alloc< BA, PA, APool >::alloc_pool_p_.

◆ get_ptr_allocator()

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

Returns copy of the ptr allocator object.

Definition at line 329 of file bmalloc.h.

References bm::mem_alloc< BA, PA, APool >::block_alloc_.

◆ operator=()

template<class BA , class PA , class APool >
mem_alloc& bm::mem_alloc< BA, PA, APool >::operator= ( const mem_alloc< BA, PA, APool > &  ma)
inline

◆ set_pool()

template<class BA , class PA , class APool >
void bm::mem_alloc< BA, PA, APool >::set_pool ( allocator_pool_type pool)
inline

set pointer to external pool

Definition at line 335 of file bmalloc.h.

References bm::mem_alloc< BA, PA, APool >::alloc_pool_p_.


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