]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
configure option for memory allocation debugging.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 5 Sep 2007 13:47:23 +0000 (13:47 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 5 Sep 2007 13:47:23 +0000 (13:47 +0000)
git-svn-id: file:///svn/unbound/trunk@598 be551aaa-1e26-0410-a405-d3ace91eadb9

configure.ac
daemon/worker.c
doc/Changelog

index 16d89fe8bf9626515f645680ff0ddcf736408f1a..f2db4bdaafce053bef4d248aade18908ec478b7e 100644 (file)
@@ -490,6 +490,14 @@ if test x_$enable_lock_checks = x_yes; then
        AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).])
 fi
 
+# set memory allocation checking if requested
+AC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks],
+       [ enable to check memory allocation, for debug purposes ]), 
+       , )
+if test x_$enable_alloc_checks = x_yes; then
+       AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use])
+fi
+
 # check to see if libraries are needed for these functions.
 AC_CHECK_LIB(socket, socket)
 AC_CHECK_LIB(nsl, inet_pton)
@@ -644,33 +652,11 @@ struct sockaddr_storage;
 
 #include "ldns/ldns.h"
 
-/* use statistics for allocs and frees, for debug use */
-#define UNBOUND_ALLOC_STATS
 #ifdef UNBOUND_ALLOC_STATS
-#  ifdef malloc
-#    undef malloc      /* keepoff autoheader */
-#  endif
-#  ifdef realloc
-#    undef realloc     /* keepoff autoheader */
-#  endif
-#  ifdef calloc
-#    undef calloc      /* keepoff autoheader */
-#  endif
-#  ifdef free
-#    undef free        /* keepoff autoheader */
-#  endif
-
-#if 0
 #  define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__)
 #  define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__)
 #  define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__)
 #  define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__)
-#else
-#  define malloc unbound_stat_malloc
-#  define calloc unbound_stat_calloc
-#  define free unbound_stat_free
-#  define realloc unbound_stat_realloc
-#endif
 void *unbound_stat_malloc(size_t size);
 void *unbound_stat_calloc(size_t nmemb, size_t size);
 void unbound_stat_free(void *ptr);
index f168674203db69f0ca2a3024837114805b2cf81e..6cd76b66b822a8e0d4e980a221d9e6851b87f275 100644 (file)
@@ -70,6 +70,7 @@
 /** Size of an UDP datagram */
 #define NORMAL_UDP_SIZE        512 /* bytes */
 
+#ifdef UNBOUND_ALLOC_STATS
 /** measure memory leakage */
 static void
 debug_memleak(size_t accounted, size_t heap, 
@@ -108,11 +109,14 @@ debug_total_mem(size_t calctotal)
        debug_memleak(calctotal, (size_t)total, 
                unbound_mem_alloc, unbound_mem_freed);
 }
+#endif /* UNBOUND_ALLOC_STATS */
 
 /** Report on memory usage by this thread and global */
 void
-worker_mem_report(struct worker* worker, struct serviced_query* cur_serv)
+worker_mem_report(struct worker* ATTR_UNUSED(worker), 
+       struct serviced_query* ATTR_UNUSED(cur_serv))
 {
+#ifdef UNBOUND_ALLOC_STATS
        /* debug func in validator module */
        size_t total, front, back, mesh, msg, rrset, infra, ac, superac;
        size_t me, iter, val;
@@ -153,6 +157,7 @@ worker_mem_report(struct worker* worker, struct serviced_query* cur_serv)
                (unsigned)infra, (unsigned)iter, (unsigned)val, (unsigned)ac, 
                (unsigned)superac, (unsigned)me);
        debug_total_mem(total);
+#endif /* UNBOUND_ALLOC_STATS */
 }
 
 void 
index fc75b59c6f137519224cd6dd2910e5eca3f2cbe1..3651af37d0712466d59fd052be8df37373183da6 100644 (file)
@@ -12,6 +12,7 @@
          Also, for wildcard name NSECs, check they are not from the parent
          zone (for wildcarded zone cuts), and check absence of CNAME bit,
          for a nodata proof.
+       - configure option for memory allocation debugging.
 
 4 September 2007: Wouter
        - fixup of Leakage warning when serviced queries processed multiple