wingo pushed a commit to branch wip-whippet
in repository guile.

commit e0c5adf52c0245fa99fec17aa367f24e2c9baa5f
Author: Andy Wingo <wi...@pobox.com>
AuthorDate: Wed Apr 23 15:33:52 2025 +0200

    Move scm_gc_malloc_pointerless to use Whippet API
    
    * libguile/gc-malloc.c: Trim set of includes.
    (do_gc_malloc_atomic): Remove.
    (scm_gc_malloc_pointerless): Call scm_inline_gc_malloc_pointerless.
    (scm_gc_strndup): Call scm_gc_malloc_pointerless.
---
 libguile/gc-malloc.c | 30 +++++-------------------------
 1 file changed, 5 insertions(+), 25 deletions(-)

diff --git a/libguile/gc-malloc.c b/libguile/gc-malloc.c
index fdae8add5..c88a8b631 100644
--- a/libguile/gc-malloc.c
+++ b/libguile/gc-malloc.c
@@ -23,27 +23,12 @@
 #  include <config.h>
 #endif
 
-#include <stdio.h>
-#include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
 
-#include "arrays.h"
-#include "async.h"
-#ifdef GUILE_DEBUG_MALLOC
-#include "debug-malloc.h"
-#endif
-#include "deprecation.h"
-#include "eval.h"
-#include "hashtab.h"
-#include "ports.h"
-#include "smob.h"
-#include "stackchk.h"
-#include "stime.h"
-#include "strings.h"
-#include "struct.h"
-#include "vectors.h"
+#include "gc-inline.h"
+#include "threads.h"
 
 #include "gc.h"
 
@@ -86,12 +71,6 @@ do_gc_malloc (size_t size, const char *what)
   return GC_MALLOC (size ? size : sizeof (void *));
 }
 
-static void*
-do_gc_malloc_atomic (size_t size, const char *what)
-{
-  return GC_MALLOC_ATOMIC (size ? size : sizeof (void *));
-}
-
 static void*
 do_gc_realloc (void *from, size_t size, const char *what)
 {
@@ -201,7 +180,8 @@ scm_gc_unregister_collectable_memory (void *mem, size_t 
size, const char *what)
 void *
 scm_gc_malloc_pointerless (size_t size, const char *what)
 {
-  return do_gc_malloc_atomic (size, what);
+  return scm_inline_gc_malloc_pointerless (SCM_I_CURRENT_THREAD,
+                                           size ? size : 1);
 }
 
 void *
@@ -226,7 +206,7 @@ scm_gc_realloc (void *mem, size_t old_size, size_t 
new_size, const char *what)
 char *
 scm_gc_strndup (const char *str, size_t n, const char *what)
 {
-  char *dst = do_gc_malloc_atomic (n + 1, what);
+  char *dst = scm_gc_malloc_pointerless (n + 1, what);
   memcpy (dst, str, n);
   dst[n] = 0;
   return dst;

Reply via email to