ok, this is embarrassing. carlos, is there a way to make the git 
hosting send sends an email about commits made to the list? or any 
other way to achieve this effect?

attached is the diff between takes one and two.


-- 
[-]

mkdir /nonexistent
From d9a5828fb9b8c3b2e74c347b2eff090a36402538 Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Thu, 23 Sep 2010 00:10:25 +0200
Subject: [PATCH] Repair TEST_WITH_GC

The comment in WINGs/memory.c:wfree() pretty much explains the current
situation. There's an incredible amount of mixing the wmalloc/wfree
wrappers with native mallocs/frees on the other side, and a good several
cases of misusing external libraries' APIs. Until this is thoroughly
cleaned, WM with --enable-boehm-gc will hardly even start.

Signed-off-by: Tamas TEVESZ <[email protected]>
---
 WINGs/memory.c |   44 ++++++++++++++++++++++++++++++++++++++------
 configure.ac   |    4 ++--
 2 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/WINGs/memory.c b/WINGs/memory.c
index e3859d2..0e350bf 100644
--- a/WINGs/memory.c
+++ b/WINGs/memory.c
@@ -29,12 +29,12 @@
 #include <assert.h>
 #include <signal.h>
 
-#ifdef WITH_BOEHM_GC
+#ifdef USE_BOEHM_GC
+#ifndef GC_DEBUG
+#define GC_DEBUG
+#endif /* !GC_DEBUG */
 #include <gc/gc.h>
-#define malloc(x)	GC_MALLOC(x)
-#define realloc(x, y)	GC_REALLOC(x, y)
-#define free(x)		GC_FREE(x)
-#endif /* WITH_BOEHM_GC */
+#endif /* USE_BOEHM_GC */
 
 #ifndef False
 # define False 0
@@ -74,11 +74,19 @@ void *wmalloc(size_t size)
 
 	assert(size > 0);
 
+#ifdef USE_BOEHM_GC
+	tmp = GC_MALLOC(size);
+#else
 	tmp = malloc(size);
+#endif
 	if (tmp == NULL) {
 		wwarning("malloc() failed. Retrying after 2s.");
 		sleep(2);
+#ifdef USE_BOEHM_GC
+		tmp = GC_MALLOC(size);
+#else
 		tmp = malloc(size);
+#endif
 		if (tmp == NULL) {
 			if (Aborting) {
 				fputs("Really Bad Error: recursive malloc() failure.", stderr);
@@ -103,11 +111,19 @@ void *wrealloc(void *ptr, size_t newsize)
 		wfree(ptr);
 		nptr = NULL;
 	} else {
+#ifdef USE_BOEHM_GC
+		nptr = GC_REALLOC(ptr, newsize);
+#else
 		nptr = realloc(ptr, newsize);
+#endif
 		if (nptr == NULL) {
 			wwarning("realloc() failed. Retrying after 2s.");
 			sleep(2);
+#ifdef USE_BOEHM_GC
+			nptr = GC_REALLOC(ptr, newsize);
+#else
 			nptr = realloc(ptr, newsize);
+#endif
 			if (nptr == NULL) {
 				if (Aborting) {
 					fputs("Really Bad Error: recursive realloc() failure.", stderr);
@@ -151,7 +167,23 @@ void *wretain(void *ptr)
 
 void wfree(void *ptr)
 {
-	free(ptr);
+	if (ptr)
+#ifdef USE_BOEHM_GC
+		/* This should eventually be removed, once the criss-cross
+		 * of wmalloc()d memory being free()d, malloc()d memory being
+		 * wfree()d, various misuses of calling wfree() on objects
+		 * allocated by libc malloc() and calling libc free() on
+		 * objects allocated by Boehm GC (think external libraries)
+		 * is cleaned up.
+		 */
+		if (GC_base(ptr) != 0)
+			GC_FREE(ptr);
+		else
+			free(ptr);
+#else
+		free(ptr);
+#endif
+	ptr = NULL;
 }
 
 void wrelease(void *ptr)
diff --git a/configure.ac b/configure.ac
index b834c1f..5372d57 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,7 +142,7 @@ AC_ARG_WITH(incs-from, AS_HELP_STRING([--with-incs-from], [pass compiler flags t
 	[inc_search_path="$withval $inc_search_path"])
 
 
-dnl Boehm-GC
+dnl Boehm GC
 dnl ========
 with_boehm_gc=no
 AC_ARG_ENABLE([boehm-gc],
@@ -151,7 +151,7 @@ AC_ARG_ENABLE([boehm-gc],
 
 AS_IF([test "x$with_boehm_gc" = "xyes"],
     AC_SEARCH_LIBS([GC_malloc], [gc],
-        [AC_DEFINE(WITH_BOEHM_GC, 1, [Define if Boehm GC is to be used])],
+        [AC_DEFINE(USE_BOEHM_GC, 1, [Define if Boehm GC is to be used])],
         [AC_MSG_FAILURE([--enable-boehm-gc specified but test for libgc failed])]
     )
 )
-- 
1.7.0.4

Reply via email to