MySQL  8.0.17
Source Code Documentation
wrapper_functions.h File Reference

Contains wrapper functions for memory allocation and deallocation. More...

#include "binlog_config.h"
#include "my_config.h"
#include "my_sys.h"
#include "mysql/service_mysql_alloc.h"
#include "my_dbug.h"

Go to the source code of this file.

Macros

#define HAVE_MYSYS   1
 
#define BAPI_ASSERT(x)   DBUG_ASSERT(x)
 
#define BAPI_PRINT(name, params)   DBUG_PRINT(name, params)
 
#define BAPI_ENTER(x)   DBUG_ENTER(x)
 
#define BAPI_RETURN(x)   DBUG_RETURN(x)
 
#define BAPI_VOID_RETURN   DBUG_VOID_RETURN
 

Functions

char * strndup (const char *s, size_t n)
 The strndup() function returns a pointer to a new string which is a duplicate of the string s, but it only copies at most n bytes. More...
 
const char * bapi_strndup (const char *destination, size_t n)
 This is a wrapper function, and returns a pointer to a new string which is a duplicate of the input string. More...
 
void * bapi_memdup (const void *source, size_t len)
 This is a wrapper function, and returns a pointer to a new memory with the contents copied from the input memory pointer, upto a given length. More...
 
void * bapi_malloc (size_t size, int flags)
 This is a wrapper function in order to allocate memory from the heap in the binlogevent library. More...
 
void bapi_free (void *ptr)
 This is a wrapper function in order to free the memory allocated from the heap in the binlogevent library. More...
 

Variables

PSI_memory_key key_memory_log_event
 

Detailed Description

Contains wrapper functions for memory allocation and deallocation.

This includes generic functions to be called from the binlogevent library, which call the appropriate corresponding function, depending on whether the library is compiled independently, or with the MySQL server.

Macro Definition Documentation

◆ BAPI_ASSERT

#define BAPI_ASSERT (   x)    DBUG_ASSERT(x)

◆ BAPI_ENTER

#define BAPI_ENTER (   x)    DBUG_ENTER(x)

◆ BAPI_PRINT

#define BAPI_PRINT (   name,
  params 
)    DBUG_PRINT(name, params)

◆ BAPI_RETURN

#define BAPI_RETURN (   x)    DBUG_RETURN(x)

◆ BAPI_VOID_RETURN

#define BAPI_VOID_RETURN   DBUG_VOID_RETURN

◆ HAVE_MYSYS

#define HAVE_MYSYS   1

Function Documentation

◆ bapi_free()

void bapi_free ( void *  ptr)
inline

This is a wrapper function in order to free the memory allocated from the heap in the binlogevent library.

If compiled with the MySQL server, and memory is allocated using memory allocating methods from the mysys library, my_free is called. Otherwise, the standard free() is called from the function.

Parameters
ptrPointer to the memory which is to be freed.

◆ bapi_malloc()

void* bapi_malloc ( size_t  size,
int  flags 
)
inline

This is a wrapper function in order to allocate memory from the heap in the binlogevent library.

If compiled with the MySQL server, and memory is allocated using memory allocating methods from the mysys library, my_malloc is called. Otherwise, the standard malloc() is called from the function.

Parameters
sizeSize of the memory to be allocated.
flagsflags to pass to MySQL server my_malloc functions
Returns
Void pointer to the allocated chunk of memory

◆ bapi_memdup()

void* bapi_memdup ( const void *  source,
size_t  len 
)
inline

This is a wrapper function, and returns a pointer to a new memory with the contents copied from the input memory pointer, upto a given length.

Parameters
sourcePointer to the buffer from which data is to be copied
lenLength upto which the source should be copied
Returns
dest pointer to a new memory if allocation was successful NULL otherwise

◆ bapi_strndup()

const char* bapi_strndup ( const char *  destination,
size_t  n 
)
inline

This is a wrapper function, and returns a pointer to a new string which is a duplicate of the input string.

The terminating Null character is added.

If compiled with MySQL server,the strndup function from the mysys library is called, which allow instrumenting memory allocated. Else, the standard string function is called.

Parameters
destinationThe string to be duplicated
nThe number of bytes to be copied
Returns
The duplicated string, or NULL if insufficient memory was available.

◆ strndup()

char* strndup ( const char *  s,
size_t  n 
)
inline

The strndup() function returns a pointer to a new string which is a duplicate of the string s, but it only copies at most n bytes.

If s is longer than n, only n bytes are copied, and a terminating null byte ('\0') is added. Memory for the new string is obtained with malloc, and can be freed with free.

Parameters
sThe string whose copy we want to create
nNumber of bytes to be copied
Returns
The duplicated string, or NULL if insufficient memory was available.

Variable Documentation

◆ key_memory_log_event

PSI_memory_key key_memory_log_event