ext/xml/ruby_xml_parser.c in libxml-ruby-0.5.1.0 vs ext/xml/ruby_xml_parser.c in libxml-ruby-0.5.2.0

- old
+ new

@@ -1,17 +1,15 @@ -/* $Id: ruby_xml_parser.c 138 2007-08-29 18:00:35Z danj $ */ -/* $Id: ruby_xml_parser.c 138 2007-08-29 18:00:35Z danj $ */ +/* $Id: ruby_xml_parser.c 192 2007-10-05 15:13:17Z danj $ */ /* Please see the LICENSE file for copyright and distribution information */ #include <stdarg.h> #include "libxml.h" static VALUE libxml_xmlRubyErrorProc = Qnil; static int id_call; -int ruby_xml_parser_count = 0; VALUE cXMLParser; VALUE eXMLParserParseError; static int ctxtRead(FILE *f, char * buf, int len) { @@ -796,14 +794,10 @@ void ruby_xml_parser_free(ruby_xml_parser *rxp) { void *data; - ruby_xml_parser_count--; - if (ruby_xml_parser_count == 0) - xmlCleanupParser(); - switch(rxp->data_type) { case RUBY_LIBXML_SRC_TYPE_NULL: break; case RUBY_LIBXML_SRC_TYPE_FILE: data = (void *)(rx_file_data *)rxp->data; @@ -938,10 +932,12 @@ void ruby_xml_parser_mark(ruby_xml_parser *rxp) { if (rxp == NULL) return; if (!NIL_P(rxp->ctxt)) rb_gc_mark(rxp->ctxt); + ruby_xml_state_marker(); + switch(rxp->data_type) { case RUBY_LIBXML_SRC_TYPE_NULL: break; case RUBY_LIBXML_SRC_TYPE_FILE: if (!NIL_P(((rx_file_data *)rxp->data)->filename)) @@ -1005,19 +1001,23 @@ * Create a new parser instance with no pre-determined source. */ VALUE ruby_xml_parser_new(VALUE class) { ruby_xml_parser *rxp; + VALUE r; - ruby_xml_parser_count++; - rxp = ALLOC(ruby_xml_parser); + r=Data_Make_Struct(class, + ruby_xml_parser, + ruby_xml_parser_mark, + ruby_xml_parser_free, + rxp); + rxp->ctxt = Qnil; rxp->data_type = RUBY_LIBXML_SRC_TYPE_NULL; rxp->data = NULL; rxp->parsed = 0; - return(Data_Wrap_Struct(class, ruby_xml_parser_mark, - ruby_xml_parser_free, rxp)); + return r; } /* * call-seq: