From: Francesco Chemolli Date: Mon, 17 Mar 2014 11:04:57 +0000 (+0100) Subject: Remove XMALLOC_DEBUG X-Git-Tag: SQUID_3_5_0_1~327^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3ca55de1391c9b21f74f53c7782925a830d03425;p=thirdparty%2Fsquid.git Remove XMALLOC_DEBUG --- diff --git a/compat/xalloc.cc b/compat/xalloc.cc index 144af386e2..6265b3f711 100644 --- a/compat/xalloc.cc +++ b/compat/xalloc.cc @@ -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(s_const); PROF_start(free_const); - -#if XMALLOC_DEBUG - check_free(s); -#endif - PROF_start(free); free(s); PROF_stop(free); diff --git a/configure.ac b/configure.ac index df08124689..28e20ec0cf 100644 --- a/configure.ac +++ b/configure.ac @@ -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], diff --git a/lib/malloc_trace.cc b/lib/malloc_trace.cc index 7483c96768..cecb771760 100644 --- a/lib/malloc_trace.cc +++ b/lib/malloc_trace.cc @@ -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 -