XMALLOC_DEBUG

From: Andres Kroonmaa <andre@dont-contact.us>
Date: Fri, 17 Nov 2000 13:11:18 +0200

 few changes to fix for XMALLOC_DEBUG:
 - check_free shouldn't be called with a NULL pointer
 - I needed to increase DBG_ARRY_SZ to handle larger alloc count
   (perhaps should we use realloc here to grow dynamically?)
 - cf_gen.c used inconsitently alloc funcs: xcalloc() but free(),
   resulting in check_free() to assert during make using cf_gen

--- HEAD/lib/util.c Mon Nov 13 23:51:59 2000
+++ HEAD-pools/lib/util.c Thu Nov 16 22:57:09 2000
@@ -170,21 +170,21 @@
 size_t xmalloc_total = 0;
 #undef xmalloc
 #undef xfree
 #undef xxfree
 #undef xrealloc
 #undef xcalloc
 #undef xstrdup
 #endif
 
 #if XMALLOC_DEBUG
-#define DBG_ARRY_SZ (1<<10)
+#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];
 #if XMALLOC_TRACE
 static char *malloc_file[DBG_ARRY_BKTS][DBG_ARRY_SZ];
 static short malloc_line[DBG_ARRY_BKTS][DBG_ARRY_SZ];
 static int malloc_count[DBG_ARRY_BKTS][DBG_ARRY_SZ];
 #endif
 static int dbg_initd = 0;
 
@@ -467,21 +467,22 @@
  * xfree() - same as free(3). Will not call free(3) if s == NULL.
  */
 void
 xfree(void *s)
 {
 #if XMALLOC_TRACE
     xmalloc_show_trace(s, -1);
 #endif
 
 #if XMALLOC_DEBUG
- check_free(s);
+ if (s != NULL)
+ check_free(s);
 #endif
     if (s != NULL)
        free(s);
 #if MEM_GEN_TRACE
     if (tracefp && s)
        fprintf(tracefp, "f:%p\n", s);
 #endif
 }
 
 /* xxfree() - like xfree(), but we already know s != NULL */

Index: cf_gen.c
===================================================================
RCS file: /cvsroot/squid/squid/src/cf_gen.c,v
retrieving revision 1.3
diff -u -r1.3 cf_gen.c
--- cf_gen.c 2000/10/23 15:04:20 1.3
+++ cf_gen.c 2000/11/16 20:09:19
@@ -608,8 +608,8 @@
                 line = def;
                 def = line->next;
                 fprintf(fp, "# %s\n", line->data);
- free(line->data);
- free(line);
+ xfree(line->data);
+ xfree(line);
             }
             blank = 1;
         }

------------------------------------
 Andres Kroonmaa <andre@online.ee>
 Delfi Online
 Tel: 6501 731, Fax: 6501 708
 Pärnu mnt. 158, Tallinn,
 11317 Estonia
Received on Fri Nov 17 2000 - 04:14:21 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:59 MST