poison: added valgrind support
If the header valgrind/memcheck.h is available, add VALGRIND_MAKE_MEM_NOACCESS() and VALGRIND_MAKE_MEM_UNDEFINED() support, which enables nice warnings in the valgrind memory checker.
This commit is contained in:
		| @@ -101,6 +101,7 @@ AC_CHECK_LIB(nsl,gethostbyname,MPD_LIBS="$MPD_LIBS -lnsl",) | |||||||
| AC_CHECK_LIB(m,exp,MPD_LIBS="$MPD_LIBS -lm",) | AC_CHECK_LIB(m,exp,MPD_LIBS="$MPD_LIBS -lm",) | ||||||
|  |  | ||||||
| AC_CHECK_HEADERS(locale.h) | AC_CHECK_HEADERS(locale.h) | ||||||
|  | AC_CHECK_HEADERS(valgrind/memcheck.h) | ||||||
|  |  | ||||||
|  |  | ||||||
| dnl | dnl | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								src/poison.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/poison.h
									
									
									
									
									
								
							| @@ -20,6 +20,12 @@ | |||||||
| #define MPD_POISON_H | #define MPD_POISON_H | ||||||
|  |  | ||||||
| #ifndef NDEBUG | #ifndef NDEBUG | ||||||
|  | #include "config.h" | ||||||
|  |  | ||||||
|  | #ifdef HAVE_VALGRIND_MEMCHECK_H | ||||||
|  | #include <valgrind/memcheck.h> | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -37,6 +43,10 @@ poison_noaccess(void *p, size_t length) | |||||||
| 	(void)length; | 	(void)length; | ||||||
| #else | #else | ||||||
| 	memset(p, 0x01, length); | 	memset(p, 0x01, length); | ||||||
|  |  | ||||||
|  | #ifdef HAVE_VALGRIND_MEMCHECK_H | ||||||
|  | 	VALGRIND_MAKE_MEM_NOACCESS(p, length); | ||||||
|  | #endif | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -54,6 +64,10 @@ poison_undefined(void *p, size_t length) | |||||||
| 	(void)length; | 	(void)length; | ||||||
| #else | #else | ||||||
| 	memset(p, 0x02, length); | 	memset(p, 0x02, length); | ||||||
|  |  | ||||||
|  | #ifdef HAVE_VALGRIND_MEMCHECK_H | ||||||
|  | 	VALGRIND_MAKE_MEM_UNDEFINED(p, length); | ||||||
|  | #endif | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann