XEmacs's definition of xfree() as a macro taking two arguments collides
violently with <dmalloc.h>'s definition of xmalloc() as a (quite
different) macro taking one argument.
Given that all including <dmalloc.h> is giving us is reporting of line
numbers of allocations, and that even that is only provided in alloc.c,
and that those line numbers are basically always going to be one of a
very small set in XEmacs, the easiest way to fix this is to simply not
bother including <dmalloc.h> at all: dmalloc still works as long as
XEmacs is linked with -ldmalloc (which it still is when
--with-debug-malloc is on.)
(Some parts of lwlib still include it, but all include files which may
be included by XEmacs proper are dmalloc.h-clean. If we want better
coverage, we can add it to lwlib alone, rather than polluting XEmacs
with it.)
As an additional wrinkle, the Doug Lea malloc() has always had an
overhead of at least 4 bytes per allocated chunk (8 bytes per chunk for
machines with 8-bit pointers, more if this is a large request satisfied
via mmap() rather than via arena allocation). For now, 4 bytes is more
accurate than the previous figure of, um, 0. (What malloc() has no bytes
of overhead?! How on earth would it track blocks?)
(Note that with that patch XEmacs compiles, but crashes down inside
libfontconfig as soon as it starts under dmalloc. This may be a
fontconfig-specific weirdness. Investigating.)
lwlib changelog:
2006-12-28 Nix <nix(a)esperi.org.uk>
* lwlib-utils.h (USE_DEBUG_MALLOC): Do not include dmalloc.h.
src changelog:
2006-12-28 Nix <nix(a)esperi.org.uk>
* alloc.c (USE_DEBUG_MALLOC): Do not include dmalloc.h.
* gc.h: Improve overhead estimate for dlmalloc.
Index: 21.5/lwlib/lwlib-utils.h
===================================================================
--- 21.5.orig/lwlib/lwlib-utils.h 2001-04-16 23:21:29.000000000 +0100
+++ 21.5/lwlib/lwlib-utils.h 2006-12-28 22:23:57.000000000 +0000
@@ -18,8 +18,4 @@
void XtSafelyDestroyWidget (Widget);
-#ifdef USE_DEBUG_MALLOC
-#include <dmalloc.h>
-#endif
-
#endif /* INCLUDED_lwlib_utils_h_ */
Index: 21.5/src/alloc.c
===================================================================
--- 21.5.orig/src/alloc.c 2006-10-24 19:28:56.000000000 +0100
+++ 21.5/src/alloc.c 2006-12-28 22:03:46.000000000 +0000
@@ -84,7 +84,6 @@
the hope being that some debugging tools may help detect
freed memory references */
#ifdef USE_DEBUG_MALLOC /* Taking the above comment at face value -slb */
-#include <dmalloc.h>
#define ALLOC_NO_POOLS
#endif
Index: 21.5/src/gc.h
===================================================================
--- 21.5.orig/src/gc.h 2006-03-28 18:43:54.000000000 +0100
+++ 21.5/src/gc.h 2006-12-28 22:05:18.000000000 +0000
@@ -85,7 +85,9 @@
/************************************************************************/
#ifndef MALLOC_OVERHEAD
-#ifdef GNU_MALLOC
+#if defined (DOUG_LEA_MALLOC)
+#define MALLOC_OVERHEAD 4 /* Minimum, assuming 4-byte pointers */
+#elif defined (GNU_MALLOC)
#define MALLOC_OVERHEAD 0
#elif defined (rcheck)
#define MALLOC_OVERHEAD 20
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches