MySQL 9.0.0
Source Code Documentation
my_malloc.cc File Reference
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "memory_debugging.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_psi_config.h"
#include "my_sys.h"
#include "my_thread_local.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/psi/mysql_memory.h"
#include "mysql/psi/psi_memory.h"
#include "mysys_err.h"

Macros

#define USE_MALLOC_WRAPPER
 

Typedefs

typedef void *(* allocator_func) (size_t, myf)
 
typedef void *(* realloc_func) (void *, size_t)
 
typedef void(* deallocator_func) (void *)
 

Functions

static void * std_allocator (size_t size, myf my_flags)
 
static void std_deallocator (void *ptr)
 
static void * redirecting_allocator (size_t size, myf my_flags)
 
static void redirecting_deallocator (void *ptr)
 
template<allocator_func allocator>
void * my_raw_malloc (size_t size, myf my_flags)
 Allocate a sized block of memory. More...
 
template<deallocator_func deallocator>
void my_raw_free (void *ptr)
 Free memory allocated with my_raw_malloc. More...
 
template<allocator_func allocator>
void * my_internal_malloc (PSI_memory_key key, size_t size, myf flags)
 
void * my_malloc (PSI_memory_key key, size_t size, myf flags)
 Allocates size bytes of memory. More...
 
void * my_std_malloc (PSI_memory_key key, size_t size, myf flags)
 
template<deallocator_func deallocator>
void my_internal_free (void *ptr)
 
template<allocator_func allocator, deallocator_func deallocator>
void * my_internal_realloc (PSI_memory_key key, void *ptr, size_t size, myf flags)
 
void * my_realloc (PSI_memory_key key, void *ptr, size_t size, myf flags)
 
void * my_std_realloc (PSI_memory_key key, void *ptr, size_t size, myf flags)
 
void my_claim (const void *ptr, bool claim)
 
void my_free (void *ptr)
 Frees the memory pointed by the ptr. More...
 
void my_std_free (void *ptr)
 
void * my_memdup (PSI_memory_key key, const void *from, size_t length, myf my_flags)
 
char * my_strdup (PSI_memory_key key, const char *from, myf my_flags)
 
char * my_strndup (PSI_memory_key key, const char *from, size_t length, myf my_flags)
 

Macro Definition Documentation

◆ USE_MALLOC_WRAPPER

#define USE_MALLOC_WRAPPER

Typedef Documentation

◆ allocator_func

typedef void *(* allocator_func) (size_t, myf)

◆ deallocator_func

typedef void(* deallocator_func) (void *)

◆ realloc_func

typedef void *(* realloc_func) (void *, size_t)

Function Documentation

◆ my_claim()

void my_claim ( const void *  ptr,
bool  claim 
)

◆ my_free()

void my_free ( void *  ptr)

Frees the memory pointed by the ptr.

Parameters
ptrmemory address to be freed

◆ my_internal_free()

template<deallocator_func deallocator>
void my_internal_free ( void *  ptr)

◆ my_internal_malloc()

template<allocator_func allocator>
void * my_internal_malloc ( PSI_memory_key  key,
size_t  size,
myf  flags 
)

◆ my_internal_realloc()

template<allocator_func allocator, deallocator_func deallocator>
void * my_internal_realloc ( PSI_memory_key  key,
void *  ptr,
size_t  size,
myf  flags 
)

◆ my_malloc()

void * my_malloc ( PSI_memory_key  key,
size_t  size,
int  flags 
)

Allocates size bytes of memory.

Parameters
keyP_S key used for memory instrumentation
sizesize bytes to allocate the memory
flagsused at the time of allocation. Could be MY_ZEROFILL

◆ my_memdup()

void * my_memdup ( PSI_memory_key  key,
const void *  from,
size_t  length,
myf  my_flags 
)

◆ my_raw_free()

template<deallocator_func deallocator>
void my_raw_free ( void *  ptr)

Free memory allocated with my_raw_malloc.

Remarks
Relies on free being able to handle a NULL argument.
Parameters
ptrPointer to the memory allocated by my_raw_malloc.

◆ my_raw_malloc()

template<allocator_func allocator>
void * my_raw_malloc ( size_t  size,
myf  my_flags 
)

Allocate a sized block of memory.

Parameters
sizeThe size of the memory block in bytes.
my_flagsFailure action modifiers (bitmasks).
Returns
A pointer to the allocated memory block, or NULL on failure.

◆ my_realloc()

void * my_realloc ( PSI_memory_key  key,
void *  ptr,
size_t  size,
myf  flags 
)

◆ my_std_free()

void my_std_free ( void *  ptr)

◆ my_std_malloc()

void * my_std_malloc ( PSI_memory_key  key,
size_t  size,
myf  flags 
)

◆ my_std_realloc()

void * my_std_realloc ( PSI_memory_key  key,
void *  ptr,
size_t  size,
myf  flags 
)

◆ my_strdup()

char * my_strdup ( PSI_memory_key  key,
const char *  from,
myf  my_flags 
)

◆ my_strndup()

char * my_strndup ( PSI_memory_key  key,
const char *  from,
size_t  length,
myf  my_flags 
)

◆ redirecting_allocator()

static void * redirecting_allocator ( size_t  size,
myf  my_flags 
)
inlinestatic

◆ redirecting_deallocator()

static void redirecting_deallocator ( void *  ptr)
inlinestatic

◆ std_allocator()

static void * std_allocator ( size_t  size,
myf  my_flags 
)
inlinestatic

◆ std_deallocator()

static void std_deallocator ( void *  ptr)
inlinestatic