From ceeddfb9da97e192ced9214d98ad9b71249150ab Mon Sep 17 00:00:00 2001 From: Stu Black Date: Thu, 11 Sep 2025 17:10:07 -0400 Subject: [PATCH] Rip out Boehm GC support. This is done to simplify memory management across the boundary between C and Rust. While rewriting WINGs, we may want to be able to malloc/free with the libc allocator on both sides of that divide. --- WINGs/memory.c | 37 ------------------------------------- configure.ac | 18 ------------------ doc/build/Compilation.texi | 10 ---------- 3 files changed, 65 deletions(-) diff --git a/WINGs/memory.c b/WINGs/memory.c index e05e17a8..63a66dac 100644 --- a/WINGs/memory.c +++ b/WINGs/memory.c @@ -34,13 +34,6 @@ #include #endif -#ifdef USE_BOEHM_GC -#ifndef GC_DEBUG -#define GC_DEBUG -#endif /* !GC_DEBUG */ -#include -#endif /* USE_BOEHM_GC */ - #ifndef False # define False 0 #endif @@ -83,19 +76,11 @@ 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); @@ -122,19 +107,11 @@ 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); @@ -179,21 +156,7 @@ void *wretain(void *ptr) void wfree(void *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; } diff --git a/configure.ac b/configure.ac index f00c21a6..a20cc59e 100644 --- a/configure.ac +++ b/configure.ac @@ -351,24 +351,6 @@ AS_IF([test "x$enable_mwm_hints" = "xno"], AM_CONDITIONAL([USE_MWM_HINTS], [test "x$enable_mwm_hints" != "xno"]) -dnl Boehm GC -dnl ======== -m4_divert_push([INIT_PREPARE])dnl -AC_ARG_ENABLE([boehm-gc], - [AS_HELP_STRING([--enable-boehm-gc], [use Boehm GC instead of the default libc malloc() [default=no]])], - [AS_CASE(["$enableval"], - [yes], [with_boehm_gc=yes], - [no], [with_boehm_gc=no], - [AC_MSG_ERROR([bad value $enableval for --enable-boehm-gc])] )], - [with_boehm_gc=no]) -m4_divert_pop([INIT_PREPARE])dnl - -AS_IF([test "x$with_boehm_gc" = "xyes"], - AC_SEARCH_LIBS([GC_malloc], [gc], - [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])])) - - dnl LCOV dnl ==== m4_divert_push([INIT_PREPARE])dnl diff --git a/doc/build/Compilation.texi b/doc/build/Compilation.texi index 2265e4fd..9908bd61 100644 --- a/doc/build/Compilation.texi +++ b/doc/build/Compilation.texi @@ -253,14 +253,6 @@ If found, then the library @emph{WRaster} can use the @emph{ImageMagick} library @sc{Window Maker} support more image formats, like @emph{SVG}, @emph{BMP}, @emph{TGA}, ... You can get it from @uref{http://www.imagemagick.org/} -@item @emph{Boehm GC} - -This library can be used by the @emph{WINGs} utility toolkit to use a -@cite{Boehm-Demers-Weiser Garbage Collector} instead of the traditional -@command{malloc}/@command{free} functions from the @emph{libc}. -You have to explicitly ask for its support though (@pxref{Configure Options}). -You can get it from @uref{http://www.hboehm.info/gc/} - @end itemize @@ -468,8 +460,6 @@ You can find more information about the libraries in the @ref{Optional Dependencies}. @table @option -@item --enable-boehm-gc -Never enabled by default, use Boehm GC instead of the default @emph{libc} @command{malloc()} @item --disable-gif Disable GIF support in @emph{WRaster} library; when enabled use @file{libgif} or @file{libungif}.