1#ifndef BMALLOC__H__INCLUDED__
2#define BMALLOC__H__INCLUDED__
31#if defined(BMSSE2OPT) || defined(BMSSE42OPT)
32#define BM_ALLOC_ALIGN 16
35#define BM_ALLOC_ALIGN 32
37#if defined(BMAVX512OPT)
38#define BM_ALLOC_ALIGN 64
69#if defined(BM_ALLOC_ALIGN)
79 throw std::bad_alloc();
119#if defined(BM_ALLOC_ALIGN)
126 ptr = (
bm::word_t*) ::malloc(n *
sizeof(
void*));
130 throw std::bad_alloc();
184 pool_ptr_[size_++] = ptr;
194 return pool_ptr_[--size_];
202 void allocate_pool(
size_t pool_size)
205 pool_ptr_ = (
void**)::malloc(
sizeof(
void*) * pool_size);
207 throw std::bad_alloc();
222template<
class BA,
class PA>
289template<
class BA,
class PA,
class APool>
448 ptr = ::malloc(size);
453 throw std::bad_alloc();
455 BM_THROW(BM_ERR_BADALLOC);
471 ::_aligned_free(ptr);
#define BM_DEFAULT_POOL_SIZE
#define IS_VALID_ADDR(addr)
void set_block_limit(size_t limit) BMNOEXCEPT
void free_bit_block(bm::word_t *block) BMNOEXCEPT
size_t block_limit_
soft limit for the pool of blocks
bm::word_t * alloc_bit_block()
unsigned size() const BMNOEXCEPT
return stack size
void free_pools() BMNOEXCEPT
pointer_pool_array block_pool_
Default malloc based bitblock allocator class.
static bm::word_t * allocate(size_t n, const void *)
The member function allocates storage for an array of n bm::word_t elements, by calling malloc.
static void deallocate(bm::word_t *p, size_t) BMNOEXCEPT
The member function frees storage for an array of n bm::word_t elements, by calling free.
BM style allocator adapter.
void free_ptr(void *p, size_t size) BMNOEXCEPT
Frees block of pointers.
void set_pool(allocator_pool_type *pool) BMNOEXCEPT
set pointer to external pool
mem_alloc & operator=(const mem_alloc &ma) BMNOEXCEPT
APool allocator_pool_type
mem_alloc(const BA &block_alloc=BA(), const PA &ptr_alloc=PA()) BMNOEXCEPT
void * alloc_ptr(size_t size)
Allocates block of pointers.
void free_bit_block(bm::word_t *block, size_t alloc_factor=1) BMNOEXCEPT
Frees bit block allocated by alloc_bit_block.
allocator_pool_type * get_pool() BMNOEXCEPT
get pointer to allocation pool (if set)
bm::gap_word_t * alloc_gap_block(unsigned level, const bm::gap_word_t *glevel_len)
Allocates GAP block using bit block allocator (BA).
mem_alloc(const mem_alloc &ma) BMNOEXCEPT
block_allocator_type get_block_allocator() const BMNOEXCEPT
Returns copy of the block allocator object.
bm::word_t * alloc_bit_block(unsigned alloc_factor=1)
Allocates and returns bit block.
ptr_allocator_type get_ptr_allocator() const BMNOEXCEPT
Returns copy of the ptr allocator object.
void free_gap_block(bm::gap_word_t *block, const bm::gap_word_t *glevel_len)
Frees GAP block using bot block allocator (BA)
allocator_pool_type * alloc_pool_p_
BA & get_block_alloc() BMNOEXCEPT
Get access to block allocator.
Pool of pointers to buffer cyclic allocations.
void * pop() BMNOEXCEPT
Get a pointer if there are any vacant.
pointer_pool_array(const pointer_pool_array &)=delete
pointer_pool_array & operator=(const pointer_pool_array &)=delete
unsigned size() const BMNOEXCEPT
return stack size
unsigned push(void *ptr) BMNOEXCEPT
Push pointer to the pool (if it is not full)
Default malloc based bitblock allocator class.
static void * allocate(size_t n, const void *)
The member function allocates storage for an array of n void* elements, by calling malloc.
static void deallocate(void *p, size_t) BMNOEXCEPT
The member function frees storage for an array of n bm::word_t elements, by calling free.
bm::alloc_pool< block_allocator, ptr_allocator > standard_alloc_pool
bm::mem_alloc< block_allocator, ptr_allocator, standard_alloc_pool > standard_allocator
unsigned gap_capacity(const T *BMRESTRICT buf, const T *BMRESTRICT glevel_len) BMNOEXCEPT
Returs GAP block capacity.
void aligned_free(void *ptr) BMNOEXCEPT
Aligned free.
void * aligned_new_malloc(size_t size)
Aligned malloc (unlike classic malloc it throws bad_alloc exception)
const unsigned gap_levels
const unsigned set_block_size
unsigned short gap_word_t