]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Debug: Do not compile allocator debug journals in unless requested.
authorMaria Matejka <mq@ucw.cz>
Tue, 1 Oct 2024 13:30:00 +0000 (15:30 +0200)
committerMaria Matejka <mq@ucw.cz>
Sun, 23 Feb 2025 18:01:48 +0000 (19:01 +0100)
These journals can become very memory-heavy when it comes to
constrained environments where every 100k of RAM matters.

configure.ac
lib/xmalloc.c
sysdep/unix/alloc.c

index 7bc4fda27506bef8d2e4c7baf15b823928c0f87f..814d59199265c5e2ba969be652fab3b0c3127031 100644 (file)
@@ -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
index 74348d11b2b831223bb0bfedb5d3cdc1e2c61881..3bc0939c0dfd98e45472d53028c0aff82cd91165 100644 (file)
@@ -14,7 +14,7 @@
 
 #ifndef HAVE_LIBDMALLOC
 
-#if DEBUGGING
+#if DEBUG_ALLOCATOR
 struct minfo {
   void *ptr;
   uint size;
index 61e65f9f9bd22e21377284581c0eed2f1abde310..16749454512312852a21e1adafa59b0866e5c03f 100644 (file)
@@ -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