BitMagic-C++: bm::mem_alloc< BA, PA, APool > Class Template Reference

BitMagic-C++

Public Types | Public Member Functions
bm::mem_alloc< BA, PA, APool > Class Template Reference
BitMagic Library » bvector<> container » Allocator

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_alloc & | operator= (const mem_alloc &ma) BMNOEXCEPT
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_type * | get_pool () BMNOEXCEPT
| get pointer to allocation pool (if set) More...
bm::word_t * | alloc_bit_block (unsigned alloc_factor=1)
| Allocates and returns bit block. More...
void | free_bit_block (bm::word_t *block, unsigned alloc_factor=1) BMNOEXCEPT
| Frees bit block allocated by alloc_bit_block. More...
bm::gap_word_t * | alloc_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...

## 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 254 of file bmalloc.h.

## Member Typedef Documentation

## ◆ allocator_pool_type

template<class BA , class PA , class APool >

typedef APool bm::mem_alloc< BA, PA, APool >::allocator_pool_type

Definition at line 260 of file bmalloc.h.

## ◆ block_allocator_type

template<class BA , class PA , class APool >

typedef BA bm::mem_alloc< BA, PA, APool >::block_allocator_type

Definition at line 258 of file bmalloc.h.

## ◆ ptr_allocator_type

template<class BA , class PA , class APool >

typedef PA bm::mem_alloc< BA, PA, APool >::ptr_allocator_type

Definition at line 259 of file bmalloc.h.

## Constructor & Destructor Documentation

## ◆ mem_alloc() [1/2]

template<class BA , class PA , class APool >

bm::mem_alloc< BA, PA, APool >::mem_alloc | ( | const BA & | block_alloc = `BA()`,
|  | const PA & | ptr_alloc = `PA()`
| ) |  |
| inline

Definition at line 264 of file bmalloc.h.

## ◆ mem_alloc() [2/2]

template<class BA , class PA , class APool >

bm::mem_alloc< BA, PA, APool >::mem_alloc | ( | const mem_alloc< BA, PA, APool > & | ma | ) |
| inline

Definition at line 270 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_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 316 of file bmalloc.h.

References 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

  level | GAP block level.
  glevel_len | table of level lengths

Definition at line 342 of file bmalloc.h.

References 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 366 of file bmalloc.h.

References BM_ASSERT.

## ◆ free_bit_block()

template<class BA , class PA , class APool >

void bm::mem_alloc< BA, PA, APool >::free_bit_block | ( | bm::word_t * | block,
|  | unsigned | alloc_factor = `1`
| ) |  |
| inline

Frees bit block allocated by alloc_bit_block.

Definition at line 325 of file bmalloc.h.

References 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 354 of file bmalloc.h.

References 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 374 of file bmalloc.h.

## ◆ 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 286 of file bmalloc.h.

## ◆ 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 305 of file bmalloc.h.

## ◆ 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 293 of file bmalloc.h.

## ◆ 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

Definition at line 276 of file bmalloc.h.

## ◆ 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 299 of file bmalloc.h.

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

- bmalloc.h