MySQL  8.0.18
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/psi/mysql_memory.h"
#include "mysql/psi/psi_base.h"
#include "mysql/psi/psi_memory.h"
#include "mysys_err.h"

Classes

struct  my_memory_header
 

Macros

#define USE_MALLOC_WRAPPER
 
#define HEADER_SIZE   32
 
#define MAGIC   1234
 
#define USER_TO_HEADER(P)   ((my_memory_header *)(((char *)P) - HEADER_SIZE))
 
#define HEADER_TO_USER(P)   (((char *)P) + HEADER_SIZE)
 

Typedefs

typedef struct my_memory_header my_memory_header
 

Functions

static void * my_raw_malloc (size_t size, myf my_flags)
 Allocate a sized block of memory. More...
 
static void my_raw_free (void *ptr)
 Free memory allocated with my_raw_malloc. More...
 
void my_free (void *ptr)
 
Frees the memory pointed by the ptr. More...
 
void * my_malloc (PSI_memory_key key, size_t size, myf flags)
 Below functions are used by the components. More...
 
void * my_realloc (PSI_memory_key key, void *ptr, size_t size, myf flags)
 
void my_claim (const 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

◆ HEADER_SIZE

#define HEADER_SIZE   32

◆ HEADER_TO_USER

#define HEADER_TO_USER (   P)    (((char *)P) + HEADER_SIZE)

◆ MAGIC

#define MAGIC   1234

◆ USE_MALLOC_WRAPPER

#define USE_MALLOC_WRAPPER

◆ USER_TO_HEADER

#define USER_TO_HEADER (   P)    ((my_memory_header *)(((char *)P) - HEADER_SIZE))

Typedef Documentation

◆ my_memory_header

Function Documentation

◆ my_claim()

void my_claim ( const void *  ptr)

◆ my_free()

void my_free ( void *  ptr)


Frees the memory pointed by the ptr.

Parameters
ptrmemory address to be freed

◆ my_malloc()

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

Below functions are used by the components.

And these functions will be in a static library(liblibrary_mysys.a) and the library is statically linked whenever any component needs these function.
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

◆ my_memdup()

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

◆ my_raw_free()

static void my_raw_free ( void *  ptr)
static

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()

static void * my_raw_malloc ( size_t  size,
myf  my_flags 
)
static

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_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 
)