Move extra size checks behind a config flag.

This will let us turn that flag into a generic "turn on runtime checks" flag
that guards other functionality we have planned.
This commit is contained in:
David Goldblatt
2019-03-19 16:04:35 -07:00
committed by David Goldblatt
parent 7f7935cf78
commit f4d24f05e1
4 changed files with 40 additions and 22 deletions

View File

@@ -360,7 +360,7 @@
*/
#undef JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE
/* Performs additional size-matching sanity checks when defined. */
#undef JEMALLOC_EXTRA_SIZE_CHECK
/* Performs additional safety checks when defined. */
#undef JEMALLOC_OPT_SAFETY_CHECKS
#endif /* JEMALLOC_INTERNAL_DEFS_H_ */

View File

@@ -161,6 +161,25 @@ static const bool config_log =
false
#endif
;
/*
* Are extra safety checks enabled; things like checking the size of sized
* deallocations, double-frees, etc.
*/
static const bool config_opt_safety_checks =
#if defined(JEMALLOC_EXTRA_SAFETY_CHECKS)
true
#elif defined(JEMALLOC_DEBUG)
/*
* This lets us only guard safety checks by one flag instead of two; fast
* checks can guard solely by config_opt_safety_checks and run in debug mode
* too.
*/
true
#else
false
#endif
;
#if defined(_WIN32) || defined(JEMALLOC_HAVE_SCHED_GETCPU)
/* Currently percpu_arena depends on sched_getcpu. */
#define JEMALLOC_PERCPU_ARENA