From 6cb78350dad6c1aa9964540eccb76d3ffb8474cf Mon Sep 17 00:00:00 2001
From: Martin Stjernholm <mast@lysator.liu.se>
Date: Fri, 15 Sep 2000 02:59:39 +0200
Subject: [PATCH] Fixed gc debug checks for strings.

Rev: src/gc.h:1.67
Rev: src/stralloc.c:1.101
---
 src/gc.h       | 18 +++++++++++++++++-
 src/stralloc.c |  4 ++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/gc.h b/src/gc.h
index bf7356c743..d58facf35a 100644
--- a/src/gc.h
+++ b/src/gc.h
@@ -1,5 +1,5 @@
 /*
- * $Id: gc.h,v 1.66 2000/09/15 00:30:55 mast Exp $
+ * $Id: gc.h,v 1.67 2000/09/15 00:59:39 mast Exp $
  */
 #ifndef GC_H
 #define GC_H
@@ -50,13 +50,29 @@ extern void *gc_svalue_location;
 #endif
 
 #ifdef PIKE_DEBUG
+
+/* Use this when freeing blocks that you've used any gc_check or
+ * gc_mark function on and that can't contain references. */
+#define GC_FREE_SIMPLE_BLOCK(PTR) do {					\
+  extern int d_flag;							\
+  if(d_flag) CHECK_INTERPRETER_LOCK();					\
+  if (Pike_in_gc == GC_PASS_CHECK)					\
+    fatal("No free is allowed in this gc pass.\n");			\
+  else									\
+    remove_marker(PTR);							\
+} while (0)
+
+/* Use this when freeing blocks that you've used any gc_check or
+ * gc_mark function on and that can contain references. */
 #define GC_FREE_BLOCK(PTR) do {						\
   extern int d_flag;							\
   if(d_flag) CHECK_INTERPRETER_LOCK();					\
   if (Pike_in_gc > GC_PASS_PREPARE && Pike_in_gc < GC_PASS_FREE)	\
     fatal("Freeing objects within gc is not allowed.\n");		\
 } while (0)
+
 #else
+#define GC_FREE_SIMPLE_BLOCK(PTR) do {} while (0)
 #define GC_FREE_BLOCK(PTR) do {} while (0)
 #endif
 
diff --git a/src/stralloc.c b/src/stralloc.c
index e41e056c08..c03d208d01 100644
--- a/src/stralloc.c
+++ b/src/stralloc.c
@@ -25,7 +25,7 @@
 #define HUGE HUGE_VAL
 #endif /*!HUGE*/
 
-RCSID("$Id: stralloc.c,v 1.100 2000/09/14 19:58:44 mast Exp $");
+RCSID("$Id: stralloc.c,v 1.101 2000/09/15 00:59:39 mast Exp $");
 
 #define BEGIN_HASH_SIZE 997
 #define MAX_AVG_LINK_LENGTH 3
@@ -742,7 +742,7 @@ PMOD_EXPORT void really_free_string(struct pike_string *s)
 #endif
   unlink_pike_string(s);
   debug_free((char *)s,DMALLOC_LOCATION(),1);
-  GC_FREE_BLOCK(s);
+  GC_FREE_SIMPLE_BLOCK(s);
 }
 
 PMOD_EXPORT void debug_free_string(struct pike_string *s)
-- 
GitLab