]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove XMALLOC_DEBUG
authorFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 17 Mar 2014 11:04:57 +0000 (12:04 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 17 Mar 2014 11:04:57 +0000 (12:04 +0100)
compat/xalloc.cc
configure.ac
lib/malloc_trace.cc

index 144af386e281ea84eadbe154ebd79c2adc7ad6ca..6265b3f711f34b9919cd94f73c771eeaf6e8ed9e 100644 (file)
@@ -86,9 +86,6 @@ xcalloc(size_t n, size_t sz)
         exit(1);
     }
 
-#if XMALLOC_DEBUG
-    check_malloc(p, sz * n);
-#endif
 #if XMALLOC_STATISTICS
     malloc_stat(sz * n);
 #endif
@@ -124,9 +121,6 @@ xmalloc(size_t sz)
         exit(1);
     }
 
-#if XMALLOC_DEBUG
-    check_malloc(p, sz);
-#endif
 #if XMALLOC_STATISTICS
     malloc_stat(sz);
 #endif
@@ -147,10 +141,6 @@ xrealloc(void *s, size_t sz)
     if (sz < 1)
         sz = 1;
 
-#if XMALLOC_DEBUG
-    if (s != NULL)
-        check_free(s);
-#endif
     PROF_start(realloc);
     void *p= realloc(s, sz);
     PROF_stop(realloc);
@@ -167,9 +157,6 @@ xrealloc(void *s, size_t sz)
         exit(1);
     }
 
-#if XMALLOC_DEBUG
-    check_malloc(p, sz);
-#endif
 #if XMALLOC_STATISTICS
     malloc_stat(sz);
 #endif
@@ -187,11 +174,6 @@ free_const(const void *s_const)
     void *s = const_cast<void *>(s_const);
 
     PROF_start(free_const);
-
-#if XMALLOC_DEBUG
-    check_free(s);
-#endif
-
     PROF_start(free);
     free(s);
     PROF_stop(free);
index df081246891447744a4bb6266ee642469c6130fb..28e20ec0cf91e4eb16bdd1362e4014fca6f960cd 100644 (file)
@@ -449,16 +449,6 @@ dnl Nasty hack to get autoconf 2.64 on Linux to run.
 dnl all other uses of RUN_IFELSE are wrapped inside CACHE_CHECK which breaks on 2.64
 AC_RUN_IFELSE([AC_LANG_SOURCE([[ int main(int argc, char **argv) { return 0; } ]])],[],[],[:])
 
-dnl This is a developer only option.. developers know how to set defines
-dnl
-dnl AC_ARG_ENABLE(xmalloc-debug,
-dnl [  --enable-xmalloc-debug  Do some simple malloc debugging],
-dnl [ if test "$enableval" = "yes" ; then
-dnl     AC_MSG_NOTICE([malloc debugging enabled])
-dnl     AC_DEFINE(XMALLOC_DEBUG,1,[Define to do simple malloc debugging])
-dnl   fi
-dnl ])
-
 AH_TEMPLATE(XMALLOC_STATISTICS,[Define to have malloc statistics])
 AC_ARG_ENABLE(xmalloc-statistics,
   AS_HELP_STRING([--enable-xmalloc-statistics],
index 7483c96768162ee5970d8e8c9b9740f4754632e0..cecb77176054aa6a35f92e506a688663c9390b0c 100644 (file)
@@ -74,101 +74,3 @@ log_trace_done()
 
 #endif
 
-#if XMALLOC_DEBUG
-#define DBG_ARRY_SZ (1<<11)
-#define DBG_ARRY_BKTS (1<<8)
-static void *(*malloc_ptrs)[DBG_ARRY_SZ];
-static int malloc_size[DBG_ARRY_BKTS][DBG_ARRY_SZ];
-static int dbg_initd = 0;
-
-#define DBG_HASH_BUCKET(ptr)   (((((int)ptr)>>4)+(((int)ptr)>>12)+(((int)ptr)>>20))&0xFF)
-
-static void
-check_init(void)
-{
-    int B = 0, I = 0;
-    /* calloc the ptrs so that we don't see them when hunting lost memory */
-    malloc_ptrs = calloc(DBG_ARRY_BKTS, sizeof(*malloc_ptrs));
-
-    for (B = 0; B < DBG_ARRY_BKTS; ++B) {
-        for (I = 0; I < DBG_ARRY_SZ; ++I) {
-            malloc_ptrs[B][I] = NULL;
-            malloc_size[B][I] = 0;
-        }
-    }
-
-    dbg_initd = 1;
-}
-
-static void
-check_free(void *s)
-{
-    int B, I;
-    B = DBG_HASH_BUCKET(s);
-
-    for (I = 0; I < DBG_ARRY_SZ; ++I) {
-        if (malloc_ptrs[B][I] != s)
-            continue;
-
-        malloc_ptrs[B][I] = NULL;
-        malloc_size[B][I] = 0;
-        break;
-    }
-
-    if (I == DBG_ARRY_SZ) {
-        static char msg[128];
-        snprintf(msg, 128, "xfree: ERROR: s=%p not found!", s);
-        if (failure_notify)
-            (*failure_notify) (msg);
-        else
-            perror(msg);
-    }
-}
-
-static void
-check_malloc(void *p, size_t sz)
-{
-    void *P, *Q;
-    int B, I;
-
-    if (!dbg_initd)
-        check_init();
-
-    B = DBG_HASH_BUCKET(p);
-
-    for (I = 0; I < DBG_ARRY_SZ; ++I) {
-        if (!(P = malloc_ptrs[B][I]))
-            continue;
-
-        Q = P + malloc_size[B][I];
-
-        if (P <= p && p < Q) {
-            static char msg[128];
-            snprintf(msg, 128, "xmalloc: ERROR: p=%p falls in P=%p+%d",
-                     p, P, malloc_size[B][I]);
-            if (failure_notify)
-                (*failure_notify) (msg);
-            else
-                perror(msg);
-        }
-    }
-
-    for (I = 0; I < DBG_ARRY_SZ; ++I) {
-        if (malloc_ptrs[B][I])
-            continue;
-
-        malloc_ptrs[B][I] = p;
-        malloc_size[B][I] = (int) sz;
-        break;
-    }
-
-    if (I == DBG_ARRY_SZ) {
-        if (failure_notify)
-            (*failure_notify) ("xmalloc: debug out of array space!");
-        else
-            perror("xmalloc: debug out of array space!");
-    }
-}
-
-#endif
-