Commit 0c188d5e authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Make TRASH_FREED_MEMORY a cmake option, similar to SAFEMALLOC

parent 5c93509a
......@@ -289,6 +289,16 @@ ELSEIF(WITH_SAFEMALLOC MATCHES "AUTO" AND NOT WIN32 AND NOT WITH_VALGRIND)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC")
ENDIF()
# Another memory debugging feature
SET(THRASH_FREED_MEMORY "AUTO" CACHE STRING "Fill freed memory with specific byte pattern. Will result in slower execution. Options are: ON OFF AUTO.")
MARK_AS_ADVANCED(THRASH_FREED_MEMORY)
IF(THRASH_FREED_MEMORY MATCHES "ON")
ADD_DEFINITIONS( -DTHRASH_FREED_MEMORY)
ELSEIF(THRASH_FREED_MEMORY MATCHES "AUTO" AND NOT WIN32 AND NOT WITH_VALGRIND AND NOT WITH_ASAN)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DTHRASH_FREED_MEMORY")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTHRASH_FREED_MEMORY")
ENDIF()
# Set commonly used variables
IF(WIN32)
SET(DEFAULT_MYSQL_HOME "C:/Program Files/MariaDB ${MYSQL_BASE_VERSION}")
......
......@@ -48,7 +48,7 @@
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
#endif /* HAVE_VALGRIND_MEMCHECK_H */
#if !defined(DBUG_OFF) || defined(TRASH_FREED_MEMORY)
#if defined(TRASH_FREED_MEMORY)
#define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
#else
#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment