bm::mem_alloc< BA, PA, APool > Class Template Reference
BitMagic Library » bvector<> container » Allocator

BM style allocator adapter. More...

`#include <bmalloc.h>`

Inheritance diagram for bm::mem_alloc< BA, PA, APool >:
[legend]

## 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.
ptr_allocator_type | get_ptr_allocator () const BMNOEXCEPT
| Returns copy of the ptr allocator object.
void | set_pool (allocator_pool_type *pool) BMNOEXCEPT
| set pointer to external pool
allocator_pool_type * | get_pool () BMNOEXCEPT
| get pointer to allocation pool (if set)
bm::word_t * | alloc_bit_block (unsigned alloc_factor=1)
| Allocates and returns bit block.
void | free_bit_block (bm::word_t *block, size_t alloc_factor=1) BMNOEXCEPT
| Frees bit block allocated by alloc_bit_block.
bm::gap_word_t * | alloc_gap_block (unsigned level, const bm::gap_word_t *glevel_len)
| Allocates GAP block using bit block allocator (BA).
void | free_gap_block (bm::gap_word_t *block, const bm::gap_word_t *glevel_len)
| Frees GAP block using bot block allocator (BA).
void * | alloc_ptr (size_t size)
| Allocates block of pointers.
void | free_ptr (void *p, size_t size) BMNOEXCEPT
| Frees block of pointers.
BA & | get_block_alloc () BMNOEXCEPT
| Get access to block allocator.

## Protected Attributes

BA | block_alloc_
PA | ptr_alloc_
allocator_pool_type * | alloc_pool_p_

## 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 289 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 295 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 293 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 294 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 299 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 305 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 351 of file bmalloc.h.

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

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

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

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

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

## 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 418 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 321 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 340 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 328 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 311 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 334 of file bmalloc.h.

## Field Documentation

## alloc_pool_p_

template<class BA, class PA, class APool>

allocator_pool_type* bm::mem_alloc< BA, PA, APool >::alloc_pool_p_

protected

Definition at line 422 of file bmalloc.h.

## block_alloc_

template<class BA, class PA, class APool>

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

protected

Definition at line 420 of file bmalloc.h.

## ptr_alloc_

template<class BA, class PA, class APool>

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

protected

Definition at line 421 of file bmalloc.h.

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

- bmalloc.h