MySQL 8.4.2
Source Code Documentation
|
The memory management. More...
#include "ha_prototypes.h"
#include "mem0mem.h"
#include "buf0buf.h"
#include "srv0srv.h"
#include <stdarg.h>
Functions | |
char * | mem_heap_strdup (mem_heap_t *heap, const char *str) |
Duplicates a NUL-terminated string, allocated from a memory heap. More... | |
void * | mem_heap_dup (mem_heap_t *heap, const void *data, ulint len) |
Duplicate a block of data, allocated from a memory heap. More... | |
char * | mem_heap_strcat (mem_heap_t *heap, const char *s1, const char *s2) |
Concatenate two strings and return the result, using a memory heap. More... | |
static ulint | mem_heap_printf_low (char *buf, const char *format, va_list ap) |
Helper function for mem_heap_printf. More... | |
char * | mem_heap_printf (mem_heap_t *heap, const char *format,...) |
A simple sprintf replacement that dynamically allocates the space for the formatted string from the given heap. More... | |
void | mem_heap_validate (const mem_heap_t *heap) |
Validates the contents of a memory heap. More... | |
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... | |
mem_block_t * | mem_heap_add_block (mem_heap_t *heap, ulint n) |
Adds a new block to a memory heap. 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... | |
The memory management.
Created 6/9/1994 Heikki Tuuri
mem_block_t * mem_heap_add_block | ( | mem_heap_t * | heap, |
ulint | n | ||
) |
Adds a new block to a memory heap.
heap | in: memory heap |
n | in: number of bytes user needs |
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 |
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 |
void * mem_heap_dup | ( | mem_heap_t * | heap, |
const void * | data, | ||
ulint | len | ||
) |
Duplicate a block of data, allocated from a memory heap.
heap | in: memory heap where copy is allocated |
data | in: data to be copied |
len | in: length of data, in bytes |
void mem_heap_free_block_free | ( | mem_heap_t * | heap | ) |
Frees the free_block field from a memory heap.
in: heap
heap | in: heap |
char * mem_heap_printf | ( | mem_heap_t * | heap, |
const char * | format, | ||
... | |||
) |
A simple sprintf replacement that dynamically allocates the space for the formatted string from the given heap.
This supports a very limited set of the printf syntax: types 's' and 'u' and length modifier 'l' (which is required for the 'u' type).
heap | in: memory heap |
format | in: format string |
|
static |
Helper function for mem_heap_printf.
buf | in/out: buffer to store formatted string in, or NULL to just calculate length |
format | in: format string |
ap | in: arguments |
char * mem_heap_strcat | ( | mem_heap_t * | heap, |
const char * | s1, | ||
const char * | s2 | ||
) |
Concatenate two strings and return the result, using a memory heap.
heap | in: memory heap where string is allocated |
s1 | in: string 1 |
s2 | in: string 2 |
char * mem_heap_strdup | ( | mem_heap_t * | heap, |
const char * | str | ||
) |
Duplicates a NUL-terminated string, allocated from a memory heap.
[in] | heap | memory heap where string is allocated |
[in] | str | string to be copied |
void mem_heap_validate | ( | const mem_heap_t * | heap | ) |
Validates the contents of a memory heap.
Checks a memory heap for consistency, prints the contents if any error is detected. A fatal error is logged if an error is detected.
[in] | heap | Memory heap to validate. |