00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MPD_POISON_H
00021 #define MPD_POISON_H
00022
00023 #ifndef NDEBUG
00024 #include "config.h"
00025
00026 #ifdef HAVE_VALGRIND_MEMCHECK_H
00027 #include <valgrind/memcheck.h>
00028 #endif
00029
00030 #include <string.h>
00031 #endif
00032
00039 static inline void
00040 poison_noaccess(void *p, size_t length)
00041 {
00042 #ifdef NDEBUG
00043 (void)p;
00044 (void)length;
00045 #else
00046 memset(p, 0x01, length);
00047
00048 #ifdef HAVE_VALGRIND_MEMCHECK_H
00049 VALGRIND_MAKE_MEM_NOACCESS(p, length);
00050 #endif
00051 #endif
00052 }
00053
00060 static inline void
00061 poison_undefined(void *p, size_t length)
00062 {
00063 #ifdef NDEBUG
00064 (void)p;
00065 (void)length;
00066 #else
00067 memset(p, 0x02, length);
00068
00069 #ifdef HAVE_VALGRIND_MEMCHECK_H
00070 VALGRIND_MAKE_MEM_UNDEFINED(p, length);
00071 #endif
00072 #endif
00073 }
00074
00075
00076 #endif