Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/ext/nokogiri/xml_document.c b/ext/nokogiri/xml_document.c
index 348344c..9f035ad 100644
--- a/ext/nokogiri/xml_document.c
+++ b/ext/nokogiri/xml_document.c
@@ -38,6 +38,13 @@ static void dealloc(xmlDocPtr doc)
NOKOGIRI_DEBUG_END(doc);
}
+static void
+mark(xmlDocPtr doc)
+{
+ rb_gc_mark(DOC_RUBY_OBJECT(doc));
+ rb_gc_mark(DOC_NODE_CACHE(doc));
+}
+
static void recursively_remove_namespaces_from_node(xmlNodePtr node)
{
xmlNodePtr child ;
@@ -556,7 +563,7 @@ VALUE Nokogiri_wrap_xml_document(VALUE klass, xmlDocPtr doc)
VALUE rb_doc = Data_Wrap_Struct(
klass ? klass : cNokogiriXmlDocument,
- 0,
+ mark,
dealloc,
doc
);
diff --git a/ext/nokogiri/xml_node.c b/ext/nokogiri/xml_node.c
index 83dce9c..a46b3c8 100644
--- a/ext/nokogiri/xml_node.c
+++ b/ext/nokogiri/xml_node.c
@@ -12,11 +12,6 @@ static void debug_node_dealloc(xmlNodePtr x)
# define debug_node_dealloc 0
#endif
-static void mark(xmlNodePtr node)
-{
- rb_gc_mark(DOC_RUBY_OBJECT(node->doc));
-}
-
/* :nodoc: */
typedef xmlNodePtr (*pivot_reparentee_func)(xmlNodePtr, xmlNodePtr);
@@ -1378,9 +1373,7 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
}
}
- mark_method = node_has_a_document ? mark : NULL ;
-
- rb_node = Data_Wrap_Struct(klass, mark_method, debug_node_dealloc, node) ;
+ rb_node = Data_Wrap_Struct(klass, 0, debug_node_dealloc, node) ;
node->_private = (void *)rb_node;
if (node_has_a_document) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.