MySQL 8.0.40
Source Code Documentation
|
The memory management. More...
#include "ut0new.h"
Functions | |
mem_block_t * | mem_heap_create_block (mem_heap_t *heap, ulint n, const char *file_name, ulint line, ulint type) |
Creates a memory heap block where data can be allocated. More... | |
void | mem_heap_block_free (mem_heap_t *heap, mem_block_t *block) |
Frees a block from a memory heap. More... | |
void | mem_heap_free_block_free (mem_heap_t *heap) |
Frees the free_block field from a memory heap. More... | |
mem_block_t * | mem_heap_add_block (mem_heap_t *heap, ulint n) |
Adds a new block to a memory heap. More... | |
static void | mem_block_set_len (mem_block_t *block, ulint len) |
static ulint | mem_block_get_len (mem_block_t *block) |
static void | mem_block_set_type (mem_block_t *block, ulint type) |
static ulint | mem_block_get_type (mem_block_t *block) |
static void | mem_block_set_free (mem_block_t *block, ulint free) |
static ulint | mem_block_get_free (mem_block_t *block) |
static void | mem_block_set_start (mem_block_t *block, ulint start) |
static ulint | mem_block_get_start (mem_block_t *block) |
static void | mem_block_validate (const mem_block_t *block) |
Checks that an object is a memory heap (or a block of it) More... | |
static void * | mem_heap_zalloc (mem_heap_t *heap, ulint n) |
Allocates and zero-fills n bytes of memory from a memory heap. More... | |
static void * | mem_heap_alloc (mem_heap_t *heap, ulint n) |
Allocates n bytes of memory from a memory heap. More... | |
static void | validate_no_mans_land (byte *no_mans_land_begin, byte mem_no_mans_land_byte) |
static byte * | mem_heap_get_heap_top (mem_heap_t *heap) |
Returns a pointer to the heap top. More... | |
static void | mem_heap_free_heap_top (mem_heap_t *heap, byte *old_top) |
Frees the space in a memory heap exceeding the pointer given. More... | |
static void | mem_heap_empty (mem_heap_t *heap) |
Empties a memory heap. More... | |
static void * | mem_heap_get_top (mem_heap_t *heap, ulint n) |
Returns a pointer to the topmost element in a memory heap. More... | |
static bool | mem_heap_is_top (mem_heap_t *heap, const void *buf, ulint buf_sz) |
Checks if a given chunk of memory is the topmost element stored in the heap. More... | |
static void * | mem_heap_replace (mem_heap_t *heap, const void *top, ulint top_sz, ulint new_sz) |
Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element. More... | |
static void * | mem_heap_dup_replace (mem_heap_t *heap, const void *top, ulint top_sz, const void *data, ulint data_sz) |
Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element and then copy the specified data to it. More... | |
static char * | mem_heap_strdup_replace (mem_heap_t *heap, const void *top, ulint top_sz, const char *str) |
Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element and then copy the specified string to it. More... | |
static void | mem_heap_free_top (mem_heap_t *heap, ulint n) |
Frees the topmost element in a memory heap. More... | |
static mem_heap_t * | mem_heap_create (ulint size, ut::Location loc, ulint type) |
static void | mem_heap_free (mem_heap_t *heap) |
Frees the space occupied by a memory heap. More... | |
static size_t | mem_heap_get_size (mem_heap_t *heap) |
Returns the space in bytes occupied by a memory heap. More... | |
static char * | mem_strdup (const char *str) |
Duplicates a NUL-terminated string. More... | |
static char * | mem_strdupl (const char *str, ulint len) |
Makes a NUL-terminated copy of a nonterminated string. More... | |
static char * | mem_heap_strdupl (mem_heap_t *heap, const char *str, ulint len) |
Makes a NUL-terminated copy of a nonterminated string, allocated from a memory heap. More... | |
The memory management.
Created 6/8/1994 Heikki Tuuri
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Checks that an object is a memory heap (or a block of it)
[in] | block | Memory heap to check |
mem_block_t * mem_heap_add_block | ( | mem_heap_t * | heap, |
ulint | n | ||
) |
Adds a new block to a memory heap.
[in] | heap | memory heap |
[in] | n | number of bytes needed |
heap | in: memory heap |
n | in: number of bytes user needs |
|
inlinestatic |
Allocates n bytes of memory from a memory heap.
[in] | heap | memory heap |
[in] | n | number of bytes; if the heap is allowed to grow into the buffer pool, this must be <= MEM_MAX_ALLOC_IN_BUF |
void mem_heap_block_free | ( | mem_heap_t * | heap, |
mem_block_t * | block | ||
) |
Frees a block from a memory heap.
in: block to free
heap | in: heap |
block | in: block to free |
|
inlinestatic |
mem_block_t * mem_heap_create_block | ( | mem_heap_t * | heap, |
ulint | n, | ||
const char * | file_name, | ||
ulint | line, | ||
ulint | type | ||
) |
Creates a memory heap block where data can be allocated.
[in] | heap | memory heap or NULL if first block should be created |
[in] | n | number od bytes needed for user data |
[in] | file_name | file name where created |
[in] | line | line where created |
[in] | type | type of heap MEM_HEAP_DYNAMIC or MEM_HEAP_BUFFER |
|
inlinestatic |
Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element and then copy the specified data to it.
If the memory chunk specified with (top, top_sz) is the topmost element, then it will be discarded, otherwise it will be left untouched and this function will be equivallent to mem_heap_dup().
heap | in/out: memory heap |
top | in: chunk to discard if possible |
top_sz | in: size of top in bytes |
data | in: new data to duplicate |
data_sz | in: size of data in bytes |
|
inlinestatic |
Empties a memory heap.
The first memory block of the heap is not freed.
[in] | heap | heap to empty |
|
inlinestatic |
Frees the space occupied by a memory heap.
NOTE: Use the corresponding macro instead of this function.
[in] | heap | Heap to be freed |
void mem_heap_free_block_free | ( | mem_heap_t * | heap | ) |
Frees the free_block field from a memory heap.
in: heap
heap | in: heap |
|
inlinestatic |
Frees the space in a memory heap exceeding the pointer given.
The pointer must have been acquired from mem_heap_get_heap_top. The first memory block of the heap is not freed.
[in] | heap | heap from which to free |
[in] | old_top | pointer to old top of heap |
|
inlinestatic |
Frees the topmost element in a memory heap.
The size of the element must be given.
heap | in: memory heap |
n | in: size of the topmost element |
|
inlinestatic |
Returns a pointer to the heap top.
[in] | heap | memory heap |
|
inlinestatic |
Returns the space in bytes occupied by a memory heap.
heap | in: heap |
|
inlinestatic |
Returns a pointer to the topmost element in a memory heap.
The size of the element must be given.
[in] | heap | memory heap |
[in] | n | size of the topmost element |
|
inlinestatic |
Checks if a given chunk of memory is the topmost element stored in the heap.
If this is the case, then calling mem_heap_free_top() would free that element from the heap.
[in] | heap | memory heap |
[in] | buf | presumed topmost element |
[in] | buf_sz | size of buf in bytes |
|
inlinestatic |
Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element.
If the memory chunk specified with (top, top_sz) is the topmost element, then it will be discarded, otherwise it will be left untouched and this function will be equivallent to mem_heap_alloc().
heap | in/out: memory heap |
top | in: chunk to discard if possible |
top_sz | in: size of top in bytes |
new_sz | in: desired size of the new chunk |
|
inlinestatic |
Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element and then copy the specified string to it.
If the memory chunk specified with (top, top_sz) is the topmost element, then it will be discarded, otherwise it will be left untouched and this function will be equivallent to mem_heap_strdup().
heap | in/out: memory heap |
top | in: chunk to discard if possible |
top_sz | in: size of top in bytes |
str | in: new data to duplicate |
|
inlinestatic |
Makes a NUL-terminated copy of a nonterminated string, allocated from a memory heap.
heap | in: memory heap where string is allocated |
str | in: string to be copied |
len | in: length of str, in bytes |
|
inlinestatic |
Allocates and zero-fills n bytes of memory from a memory heap.
[in] | heap | memory heap |
[in] | n | number of bytes; if the heap is allowed to grow into the buffer pool, this must be <= MEM_MAX_ALLOC_IN_BUF |
|
inlinestatic |
Duplicates a NUL-terminated string.
str | in: string to be copied |
|
inlinestatic |
Makes a NUL-terminated copy of a nonterminated string.
str | in: string to be copied |
len | in: length of str, in bytes |