MySQL  8.0.18
Source Code Documentation
memory_debugging.h File Reference

Various macros useful for communicating with memory debuggers, such as Valgrind. More...

Go to the source code of this file.

Macros

#define MEM_MALLOCLIKE_BLOCK(p1, p2, p3, p4)
 
#define MEM_FREELIKE_BLOCK(p1, p2)
 
#define MEM_UNDEFINED(a, len)   ((void)0)
 
#define MEM_DEFINED_IF_ADDRESSABLE(a, len)   ((void)0)
 
#define MEM_NOACCESS(a, len)   ((void)0)
 
#define MEM_CHECK_ADDRESSABLE(a, len)   ((void)0)
 
#define TRASH(A, B)
 Put bad content in memory to be sure it will segfault if dereferenced. More...
 

Detailed Description

Various macros useful for communicating with memory debuggers, such as Valgrind.

Macro Definition Documentation

◆ MEM_CHECK_ADDRESSABLE

#define MEM_CHECK_ADDRESSABLE (   a,
  len 
)    ((void)0)

◆ MEM_DEFINED_IF_ADDRESSABLE

#define MEM_DEFINED_IF_ADDRESSABLE (   a,
  len 
)    ((void)0)

◆ MEM_FREELIKE_BLOCK

#define MEM_FREELIKE_BLOCK (   p1,
  p2 
)
Value:
do { \
} while (0)

◆ MEM_MALLOCLIKE_BLOCK

#define MEM_MALLOCLIKE_BLOCK (   p1,
  p2,
  p3,
  p4 
)
Value:
do { \
} while (0)

◆ MEM_NOACCESS

#define MEM_NOACCESS (   a,
  len 
)    ((void)0)

◆ MEM_UNDEFINED

#define MEM_UNDEFINED (   a,
  len 
)    ((void)0)

◆ TRASH

#define TRASH (   A,
 
)
Value:
do { \
void *p = (A); \
const size_t l = (B); \
MEM_CHECK_ADDRESSABLE(A, l); \
memset(p, 0x8F, l); \
MEM_UNDEFINED(A, l); \
} while (0)
const char * p
Definition: ctype-mb.cc:1232

Put bad content in memory to be sure it will segfault if dereferenced.

With Valgrind, verify that memory is addressable, and mark it undefined. We cache value of B because if B is expression which depends on A, memset() trashes value of B.