|
| | Root (size_t block_size_arg) |
| void | reset_defaults (size_t block_size, size_t prealloc_size) |
| unsigned char * | alloc (size_t Size) |
| | Allocate a chunk of memory from the Root structure provided, obtaining more memory from the heap if necessary.
|
| void | mark_blocks_free () |
| | Mark all data in blocks free for reusage.
|
| void * | memdup (const void *, size_t) |
| | Duplicate the provided block into memory allocated from within the specified Root.
|
| char * | strdup (const char *) |
| | Duplicate a null-terminated string into memory allocated from within the specified Root.
|
| char * | strdup (const char *, size_t) |
| | Copy the (not necessarily null-terminated) string into memory allocated from within the specified Root.
|
| char * | strdup (str_ref) |
| void | init (size_t block_size=ROOT_MIN_BLOCK_SIZE) |
| | Initialize memory root.
|
| bool | alloc_root_inited () const |
| void | free_root (myf MyFLAGS) |
| | Deallocate everything used by alloc_root or just move used blocks to free list if called with MY_USED_TO_FREE.
|
| void * | multi_alloc (int unused,...) |
| | Allocate many pointers at the same time.
|
| void * | calloc (size_t size) |
Definition at line 57 of file root.h.
◆ Root() [1/2]
| drizzled::memory::Root::Root |
( |
| ) |
|
|
inline |
◆ Root() [2/2]
| drizzled::memory::Root::Root |
( |
size_t | block_size_arg | ) |
|
|
inline |
◆ alloc()
| unsigned char * drizzled::memory::Root::alloc |
( |
size_t | length | ) |
|
Allocate a chunk of memory from the Root structure provided, obtaining more memory from the heap if necessary.
- Precondition
- mem_root must have been initialised via init()
- Parameters
-
| mem_root | The memory Root to allocate from |
| length | The size of the block to allocate |
- Todo
- Would this be more suitable as a member function on the Root class?
- Todo
- next part may be unneeded due to this->first_block_usage counter
Definition at line 140 of file root.cc.
◆ alloc_root_inited()
| bool drizzled::memory::Root::alloc_root_inited |
( |
| ) |
const |
|
inline |
◆ calloc()
| void * drizzled::memory::Root::calloc |
( |
size_t | size | ) |
|
|
inline |
◆ free_root()
| void drizzled::memory::Root::free_root |
( |
myf | MyFlags | ) |
|
Deallocate everything used by alloc_root or just move used blocks to free list if called with MY_USED_TO_FREE.
- Note
- One can call this function either with root block initialised with init() or with a zero:ed block. It's also safe to call this multiple times with the same mem_root.
- Parameters
-
| root | Memory root |
| MyFlags | Flags for what should be freed:
- MARK_BLOCKS_FREED Don't free blocks, just mark them free
- KEEP_PREALLOC If this is not set, then free also the preallocated block
|
Definition at line 287 of file root.cc.
◆ init()
| void drizzled::memory::Root::init |
( |
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() on this memory root.
- Parameters
-
| 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 ROOT_MIN_BLOCK_SIZE) |
Definition at line 57 of file root.cc.
◆ mark_blocks_free()
| void drizzled::memory::Root::mark_blocks_free |
( |
| ) |
|
Mark all data in blocks free for reusage.
Definition at line 245 of file root.cc.
◆ memdup()
| void * drizzled::memory::Root::memdup |
( |
const void * | str, |
|
|
size_t | len ) |
Duplicate the provided block into memory allocated from within the specified Root.
- Returns
- non-NULL pointer to a copy of the data if memory could be allocated, otherwise NULL
Definition at line 365 of file root.cc.
◆ multi_alloc()
| void * drizzled::memory::Root::multi_alloc |
( |
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
- Parameters
-
- Returns
- A pointer to the beginning of the allocated memory block in case of success or NULL if out of memory
Definition at line 212 of file root.cc.
◆ reset_defaults()
| void drizzled::memory::Root::reset_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.
- Parameters
-
| 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 81 of file root.cc.
◆ strdup() [1/3]
| char * drizzled::memory::Root::strdup |
( |
const char * | str | ) |
|
Duplicate a null-terminated string into memory allocated from within the specified Root.
Definition at line 327 of file root.cc.
◆ strdup() [2/3]
| char * drizzled::memory::Root::strdup |
( |
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 343 of file root.cc.
◆ strdup() [3/3]
| char * drizzled::memory::Root::strdup |
( |
str_ref | v | ) |
|
◆ block_num
| unsigned int drizzled::memory::Root::block_num |
allocated blocks counter
Definition at line 100 of file root.h.
◆ block_size
| size_t drizzled::memory::Root::block_size |
initial block size
Definition at line 99 of file root.h.
◆ first_block_usage
| unsigned int drizzled::memory::Root::first_block_usage |
first free block in queue test counter (if it exceed MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
Definition at line 106 of file root.h.
◆ free
blocks with free memory in it
Definition at line 82 of file root.h.
◆ min_malloc
| size_t drizzled::memory::Root::min_malloc |
if block have less memory it will be put in 'used' list
Definition at line 97 of file root.h.
◆ pre_alloc
preallocated block
Definition at line 92 of file root.h.
◆ used
blocks almost without free memory
Definition at line 87 of file root.h.
The documentation for this class was generated from the following files: