Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

byte_allocator Class Reference

high performance class for allocation More...

#include <memory.h>

Inheritance diagram for byte_allocator:

rep_allocator array_allocator< T > node_allocator< T > node_allocator< TYPENAME base_list< msg_cpp * >::_node >

List of all members.

Public Member Functions

 byte_allocator (size_t capacity=os_def_size)
 constructor
 ~byte_allocator ()
 destructor
void clear_all (bool secure=false)
 clears all memory
void clear_extra (bool secure=false)
 clears only extra chunks
void reset (bool secure=false)
 resets allocator for reusing the memory again
void * allocate (size_t size)
 allocates required array of bytes
void deallocate (void *)
 does nothing
size_t capacity () const
 returns the capacity of chunk
size_t count () const
 returns the count of chunks

Protected Attributes

const size_t _capacity
 chunk default capacity
size_t _count
 current count of allocated chunks of memory
unsigned char * _free_pos
 start position of available memory in current chunk
mem_chunk_start_chunk
 start chunk
mem_chunk_using_chunk
 current chunk

Private Member Functions

 byte_allocator (const byte_allocator &x)
 private copy constructor
byte_allocatoroperator= (const byte_allocator &x)
 private assign operator
void * new_chunk (size_t size)
 allocates new chunk of requested size
void * next_chunk (size_t size)
 tries to find the next chunk in a linked list with requested size


Detailed Description

high performance class for allocation

Definition at line 59 of file memory.h.


Constructor & Destructor Documentation

byte_allocator::byte_allocator ( const byte_allocator x  )  [private]

private copy constructor

BEGIN_TERIMBER_NAMESPACE byte_allocator::byte_allocator ( size_t  capacity = os_def_size  ) 

constructor

Parameters:
capacity  chunk capacity

Definition at line 34 of file memory.cpp.

byte_allocator::~byte_allocator (  ) 

destructor

Definition at line 39 of file memory.cpp.

References clear_all().


Member Function Documentation

byte_allocator& byte_allocator::operator= ( const byte_allocator x  )  [private]

private assign operator

void byte_allocator::clear_all ( bool  secure = false  ) 

clears all memory

Parameters:
secure  rewrite memory before release

Reimplemented in rep_allocator.

Definition at line 123 of file memory.cpp.

References mem_chunk::_chunk_size, _count, mem_chunk::_mem, mem_chunk::_next_chunk, _start_chunk, _using_chunk, and reset().

Referenced by rep_allocator::clear_all(), byte_allocator_creator::deactivate(), cluster_engine_impl::do_clustering(), memtable::uninit(), and ~byte_allocator().

void byte_allocator::clear_extra ( bool  secure = false  ) 

void * byte_allocator::allocate ( size_t  size  )  [inline]

allocates required array of bytes

Parameters:
size  size if bytes

Reimplemented in array_allocator< T >, array_allocator< terimber_index_column_info_ex >, array_allocator< var_object_map_t::mainmap_iter_t >, and array_allocator< binder >.

Definition at line 109 of file memory.hpp.

References mem_chunk::_chunk_size, _free_pos, mem_chunk::_mem, _using_chunk, ALIGNED_SIZEOF, and next_chunk().

Referenced by _stack< T, A >::_buynode(), _map< K, T, A, Pr, M >::_buynode(), _list< T, A >::_buynode(), _vector< T, A >::_buynodes(), base_string< T >::_create(), fuzzy_matcher_impl::_match(), paged_buffer::_persist(), fuzzy_matcher_impl::add(), xml_document::add_attribute(), xml_document::add_cdata(), xml_document::add_comment(), xml_document::add_element(), xml_document::add_element_desc(), xml_document::add_entity_desc(), xml_document::add_notation_desc(), xml_document::add_pi(), xml_document::add_text(), string_backet< N, M >::allocate(), array_allocator< T >::allocate(), node_allocator< T >::allocate(), byte_backet< N, M >::allocate(), dfa_token::assign(), _bitset::assign(), xml_document::assign_attribute_value(), backet_tank< N >::backet_tank(), content_children::build_children_tree(), content_children::build_dfa(), byte_consumer::byte_consumer(), byte_source::byte_source(), byte_tank< N >::byte_tank(), var_object_repository::cast_to_common_type(), dtd_processor::checkRepeation(), msg_cpp::construct(), fuzzyphonetic::convert_to_metaphone(), fuzzyphonetic::convert_to_reflection(), xml_grammar::copy(), copy_db_row(), copy_string(), copy_value(), dbserver_impl::get_param_as_numeric(), memlookup::get_value_as_numeric(), terimber_db_value_vector_impl::get_value_as_numeric(), dbserver_impl::get_value_as_numeric(), xml_designer_impl::get_xpath(), buffer_loader::load(), fuzzy_matcher_impl::make_string_lower(), fuzzyphonetic::metaphone_distance(), str_template::multibyte_to_unicode(), paged_buffer::paged_buffer(), parse_value(), dtd_processor::parseChildren(), dtd_processor::parseMixed(), fuzzy_matcher_impl::partial_intersect(), persist_value(), content_children::post_tree_build_init(), byte_source::push(), fuzzy_matcher_impl::reconstruct_string(), fuzzy_matcher_impl::remove(), room_array< T >::resize(), msg_cpp::resize(), _bitset::resize(), room_array< T >::room_array(), str_template::unicode_to_multibyte(), orcl_dbserver::v_bind_one_column(), odbc_dbserver::v_bind_one_column(), mysql_dbserver::v_bind_one_column(), orcl_dbserver::v_bind_one_param(), odbc_dbserver::v_bind_one_param(), mysql_dbserver::v_bind_one_param(), orcl_dbserver::v_convert_one_value(), odbc_dbserver::v_convert_one_value(), mysql_dbserver::v_convert_one_value(), odbc_dbserver::v_get_one_column_info(), orcl_dbserver::v_replace_quote(), odbc_dbserver::v_replace_quote(), mysql_dbserver::v_replace_quote(), and xml_document::validate_children().

void byte_allocator::deallocate ( void *   )  [inline]

does nothing

Reimplemented in rep_allocator.

Definition at line 130 of file memory.hpp.

Referenced by base_string< T >::_add(), base_string< T >::_assign(), base_string< T >::_destroy(), and room_array< T >::clear().

size_t byte_allocator::capacity (  )  const [inline]

size_t byte_allocator::count (  )  const [inline]

void * byte_allocator::new_chunk ( size_t  size  )  [private]

allocates new chunk of requested size

Parameters:
size  size in bytes

Definition at line 45 of file memory.cpp.

References _capacity, mem_chunk::_chunk_size, _count, _free_pos, mem_chunk::_mem, mem_chunk::_next_chunk, _start_chunk, and _using_chunk.

Referenced by next_chunk().

void * byte_allocator::next_chunk ( size_t  size  )  [private]

tries to find the next chunk in a linked list with requested size

Parameters:
size  size in bytes

Definition at line 78 of file memory.cpp.

References mem_chunk::_chunk_size, _free_pos, mem_chunk::_mem, mem_chunk::_next_chunk, _using_chunk, and new_chunk().

Referenced by allocate().


Member Data Documentation

const size_t byte_allocator::_capacity [protected]

chunk default capacity

Definition at line 115 of file memory.h.

Referenced by capacity(), and new_chunk().

size_t byte_allocator::_count [protected]

current count of allocated chunks of memory

Definition at line 116 of file memory.h.

Referenced by clear_all(), clear_extra(), count(), and new_chunk().

unsigned char* byte_allocator::_free_pos [protected]

start position of available memory in current chunk

Definition at line 117 of file memory.h.

Referenced by allocate(), new_chunk(), next_chunk(), and reset().

start chunk

Definition at line 118 of file memory.h.

Referenced by clear_all(), clear_extra(), new_chunk(), and reset().

current chunk

Definition at line 119 of file memory.h.

Referenced by allocate(), clear_all(), clear_extra(), new_chunk(), next_chunk(), and reset().


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


© Copyright Terimber 2003-.