MySQL 8.0.39
Source Code Documentation
|
This service provides functions to allocate memory in a connection local memory pool. More...
Go to the source code of this file.
Classes | |
struct | thd_alloc_service_st |
Macros | |
#define | MYSQL_THD THD * |
#define | MYSQL_SERVICE_THD_ALLOC_INCLUDED |
Functions | |
void * | thd_alloc (MYSQL_THD thd, size_t size) |
Allocate memory in the connection's local memory pool. More... | |
void * | thd_calloc (MYSQL_THD thd, size_t size) |
char * | thd_strdup (MYSQL_THD thd, const char *str) |
char * | thd_strmake (MYSQL_THD thd, const char *str, size_t size) |
void * | thd_memdup (MYSQL_THD thd, const void *str, size_t size) |
MYSQL_LEX_STRING * | thd_make_lex_string (MYSQL_THD thd, MYSQL_LEX_STRING *lex_str, const char *str, size_t size, int allocate_lex_string) |
Create a LEX_STRING in this connection's local memory pool. More... | |
Variables | |
struct thd_alloc_service_st * | thd_alloc_service |
This service provides functions to allocate memory in a connection local memory pool.
The memory allocated there will be automatically freed at the end of the statement, don't use it for allocations that should live longer than that. For short living allocations this is more efficient than using my_malloc and friends, and automatic "garbage collection" allows not to think about memory leaks.
The pool is best for small to medium objects, don't use it for large allocations - they are better served with my_malloc.
#define MYSQL_SERVICE_THD_ALLOC_INCLUDED |
#define MYSQL_THD THD * |
void * thd_alloc | ( | MYSQL_THD | thd, |
size_t | size | ||
) |
Allocate memory in the connection's local memory pool.
When properly used in place of my_malloc()
, this can significantly improve concurrency. Don't use this or related functions to allocate large chunks of memory. Use for temporary storage only. The memory will be freed automatically at the end of the statement; no explicit code is required to prevent memory leaks.
void * thd_calloc | ( | MYSQL_THD | thd, |
size_t | size | ||
) |
MYSQL_LEX_STRING * thd_make_lex_string | ( | MYSQL_THD | thd, |
MYSQL_LEX_STRING * | lex_str, | ||
const char * | str, | ||
size_t | size, | ||
int | allocate_lex_string | ||
) |
Create a LEX_STRING in this connection's local memory pool.
thd | user thread connection handle |
lex_str | pointer to LEX_STRING object to be initialized |
str | initializer to be copied into lex_str |
size | length of str, in bytes |
allocate_lex_string | flag: if TRUE, allocate new LEX_STRING object, instead of using lex_str value |
void * thd_memdup | ( | MYSQL_THD | thd, |
const void * | str, | ||
size_t | size | ||
) |
char * thd_strdup | ( | MYSQL_THD | thd, |
const char * | str | ||
) |
char * thd_strmake | ( | MYSQL_THD | thd, |
const char * | str, | ||
size_t | size | ||
) |
struct thd_alloc_service_st * thd_alloc_service |