static void dealloc(xmlDocPtr doc) { st_table *node_hash; NOKOGIRI_DEBUG_START(doc); node_hash = DOC_UNLINKED_NODE_HASH(doc); st_foreach(node_hash, dealloc_node_i, (st_data_t)doc); st_free_table(node_hash); free(doc->_private); /* When both Nokogiri and libxml-ruby are loaded, make sure that all nodes * have their _private pointers cleared. This is to avoid libxml-ruby's * xmlDeregisterNode callback from accessing VALUE pointers from ruby's GC * free context, which can result in segfaults. */ if (xmlDeregisterNodeDefaultValue) remove_private((xmlNodePtr)doc); xmlFreeDoc(doc); NOKOGIRI_DEBUG_END(doc); }
static void dealloc(xmlDocPtr doc) { NOKOGIRI_DEBUG_START(doc); st_table *node_hash = DOC_UNLINKED_NODE_HASH(doc); xmlDeregisterNodeFunc func = xmlDeregisterNodeDefault(NULL); st_foreach(node_hash, dealloc_node_i, (st_data_t)doc); st_free_table(node_hash); free(doc->_private); doc->_private = NULL; xmlFreeDoc(doc); xmlDeregisterNodeDefault(func); NOKOGIRI_DEBUG_END(doc); }