Public Member Functions | |
Root (size_t block_size_arg) | |
void | reset_root_defaults (size_t block_size, size_t prealloc_size) |
void * | alloc_root (size_t Size) |
Allocate a chunk of memory from the Root structure provided, obtaining more memory from the heap if necessary. | |
void * | allocate (size_t Size) |
void | mark_blocks_free () |
Mark all data in blocks free for reusage. | |
void * | memdup_root (const void *str, size_t len) |
Duplicate the provided block into memory allocated from within the specified Root. | |
char * | strdup_root (const char *str) |
Duplicate a null-terminated string into memory allocated from within the specified Root. | |
char * | strmake_root (const char *str, size_t len) |
Copy the (not necessarily null-terminated) string into memory allocated from within the specified Root. | |
void | init_alloc_root (size_t block_size=ROOT_MIN_BLOCK_SIZE) |
Initialize memory root. | |
void * | duplicate (const void *str, size_t len) |
bool | alloc_root_inited () |
void | free_root (myf MyFLAGS) |
Deallocate everything used by memory::alloc_root or just move used blocks to free list if called with MY_USED_TO_FREE. | |
void * | multi_alloc_root (int unused,...) |
Allocate many pointers at the same time. | |
Public Attributes | |
internal::UsedMemory * | free |
internal::UsedMemory * | used |
internal::UsedMemory * | pre_alloc |
size_t | min_malloc |
size_t | block_size |
initial block size | |
unsigned int | block_num |
allocated blocks counter | |
unsigned int | first_block_usage |
void(* | error_handler )(void) |
void * drizzled::memory::Root::alloc_root | ( | size_t | length | ) |
Allocate a chunk of memory from the Root structure provided, obtaining more memory from the heap if necessary.
mem_root | The memory Root to allocate from |
length | The size of the block to allocate |
void drizzled::memory::Root::free_root | ( | myf | MyFlags | ) |
Deallocate everything used by memory::alloc_root or just move used blocks to free list if called with MY_USED_TO_FREE.
root | Memory root |
MyFlags | Flags for what should be freed:
|
Definition at line 313 of file root.cc.
Referenced by drizzled::dispatch_command(), drizzled::my_print_help_inc_plugins(), and HailDBCursor::reset().
void drizzled::memory::Root::init_alloc_root | ( | size_t | block_size_arg = ROOT_MIN_BLOCK_SIZE | ) |
Initialize memory root.
This function prepares memory root for further use, sets initial size of chunk for memory allocation and pre-allocates first block if specified. Altough error can happen during execution of this function if pre_alloc_size is non-0 it won't be reported. Instead it will be reported as error in first alloc_root() on this memory root.
mem_root | memory root to initialize |
block_size | size of chunks (blocks) used for memory allocation (It is external size of chunk i.e. it should include memory required for internal structures, thus it should be no less than memory::ROOT_MIN_BLOCK_SIZE) |
void * drizzled::memory::Root::memdup_root | ( | const void * | str, |
size_t | len | ||
) |
Duplicate the provided block into memory allocated from within the specified Root.
Definition at line 390 of file root.cc.
Referenced by drizzled::Field::clone().
void * drizzled::memory::Root::multi_alloc_root | ( | int | unused, |
... | |||
) |
Allocate many pointers at the same time.
The variable arguments are a list of alternating pointers and lengths, terminated by a null pointer:
char ** pointer1
uint length1
char ** pointer2
uint length2
...
NULL
pointer1
, pointer2
etc. all point into big allocated memory area
root | Memory root |
void drizzled::memory::Root::reset_root_defaults | ( | size_t | block_size_arg, |
size_t | pre_alloc_size | ||
) |
Function aligns and assigns new value to block size; then it tries to reuse one of existing blocks as prealloc block, or malloc new one of requested size. If no blocks can be reused, all unused blocks are freed before allocation.
mem_root | memory root to change defaults of |
block_size | new value of block size. Must be greater or equal than ALLOC_ROOT_MIN_BLOCK_SIZE (this value is about 68 bytes and depends on platform and compilation flags) |
pre_alloc_size | new size of preallocated block. If not zero, must be equal to or greater than block size, otherwise means 'no prealloc'. |
Definition at line 84 of file root.cc.
Referenced by drizzled::Session::prepareForQueries().
char * drizzled::memory::Root::strmake_root | ( | const char * | str, |
size_t | len | ||
) |
Copy the (not necessarily null-terminated) string into memory allocated from within the specified Root.
Note that the string is copied according to the length specified, so null-termination is ignored. The duplicated string will be null-terminated, even if the original string wasn't (one additional byte is allocated for this purpose).
Definition at line 370 of file root.cc.
Referenced by drizzled::prepare_create_table().
unsigned int drizzled::memory::Root::first_block_usage |