]> git.wincent.com - wikitext.git/commitdiff
Partially revert "Remove GC_WRAP_STR and GC_WRAP_ARY macros"
authorWincent Colaiuta <win@wincent.com>
Fri, 8 May 2009 16:24:36 +0000 (18:24 +0200)
committerWincent Colaiuta <win@wincent.com>
Sun, 10 May 2009 15:03:36 +0000 (17:03 +0200)
Add back in the GC_WRAP_STR macro as I've now found a use for it
(specifically, inside functions like Wikitext_parser_sanitize_link_target).

This partially reverts commit ea1f3c0.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
ext/str.h

index 6509c903fc22e9c8aefdf3ee4302a1572941f9d4..5ae7d782f24f2ff8fee11145e4c7b3236506aad5 100644 (file)
--- a/ext/str.h
+++ b/ext/str.h
@@ -30,6 +30,10 @@ typedef struct
     long capacity;
 } str_t;
 
     long capacity;
 } str_t;
 
+// Mark the str struct designated by ptr as a participant in Ruby's mark-and-sweep garbage collection scheme.
+// A variable named name is placed on the C stack to prevent the structure from being prematurely collected.
+#define GC_WRAP_STR(ptr, name) volatile VALUE name __attribute__((unused)) = Data_Wrap_Struct(rb_cObject, 0, str_free, ptr)
+
 // create a new, empty string struct
 str_t *str_new(void);
 
 // create a new, empty string struct
 str_t *str_new(void);