From: Maria Matejka Date: Tue, 1 Oct 2024 13:30:00 +0000 (+0200) Subject: Debug: Do not compile allocator debug journals in unless requested. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e368ace237a027e791b8dcd0ebcef97587ff9e95;p=thirdparty%2Fbird.git Debug: Do not compile allocator debug journals in unless requested. These journals can become very memory-heavy when it comes to constrained environments where every 100k of RAM matters. --- diff --git a/configure.ac b/configure.ac index 7bc4fda27..814d59199 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,12 @@ AC_ARG_ENABLE([debug-expensive], [enable_debug_expensive=no] ) +AC_ARG_ENABLE([debug-allocator], + [AS_HELP_STRING([--enable-debug-allocator], [enable internal memory allocator journal (implies --enable-debug) @<:@no@:>@])], + [], + [enable_debug_expensive=no] +) + AC_ARG_ENABLE([memcheck], [AS_HELP_STRING([--enable-memcheck], [check memory allocations when debugging @<:@yes@:>@])], [], @@ -78,6 +84,10 @@ AC_ARG_VAR([FLEX], [location of the Flex program]) AC_ARG_VAR([BISON], [location of the Bison program]) AC_ARG_VAR([M4], [location of the M4 program]) +if test "$enable_debug_allocator" = yes; then + enable_debug=yes +fi + if test "$enable_debug_expensive" = yes; then enable_debug=yes fi @@ -449,6 +459,10 @@ if test "$enable_debug" = yes ; then if test "$enable_debug_expensive" = yes ; then AC_DEFINE([ENABLE_EXPENSIVE_CHECKS], [1], [Define to 1 if you want to run expensive consistency checks.]) fi + + if test "$enable_debug_allocator" = yes; then + AC_DEFINE([DEBUG_ALLOCATOR], [1], [Define to 1 if you want to store journals from memory allocations.]) + fi fi if test "$enable_compact_tries" = yes ; then diff --git a/lib/xmalloc.c b/lib/xmalloc.c index 74348d11b..3bc0939c0 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -14,7 +14,7 @@ #ifndef HAVE_LIBDMALLOC -#if DEBUGGING +#if DEBUG_ALLOCATOR struct minfo { void *ptr; uint size; diff --git a/sysdep/unix/alloc.c b/sysdep/unix/alloc.c index 61e65f9f9..167494545 100644 --- a/sysdep/unix/alloc.c +++ b/sysdep/unix/alloc.c @@ -56,7 +56,7 @@ alloc_preconfig(struct alloc_config *ac) # define PROTECT_PAGE(pg) # define UNPROTECT_PAGE(pg) -# if DEBUGGING +# if DEBUG_ALLOCATOR # ifdef ENABLE_EXPENSIVE_CHECKS # undef PROTECT_PAGE # undef UNPROTECT_PAGE