From ccfb6a1c6d7e941e871181d4bbaba3a5089810f0 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 3 Nov 2012 11:16:49 +0000 Subject: Change XML Parser API to be more sane --- test/testutils/load.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/testutils/load.c b/test/testutils/load.c index e072f10..2c93fc0 100644 --- a/test/testutils/load.c +++ b/test/testutils/load.c @@ -42,7 +42,7 @@ dom_document *load_xml(const char *file, bool willBeModified) UNUSED(willBeModified); - parser = dom_xml_parser_create(NULL, NULL, mymsg, NULL); + parser = dom_xml_parser_create(NULL, NULL, mymsg, NULL, &ret); if (parser == NULL) { fprintf(stderr, "Can't create XMLParser\n"); return NULL; @@ -50,6 +50,7 @@ dom_document *load_xml(const char *file, bool willBeModified) handle = open(file, O_RDONLY); if (handle == -1) { + dom_node_unref(ret); dom_xml_parser_destroy(parser); fprintf(stderr, "Can't open test input file: %s\n", file); return NULL; @@ -58,6 +59,7 @@ dom_document *load_xml(const char *file, bool willBeModified) readed = read(handle, buffer, 1024); error = dom_xml_parser_parse_chunk(parser, buffer, readed); if (error != DOM_XML_OK) { + dom_node_unref(ret); dom_xml_parser_destroy(parser); fprintf(stderr, "Parsing errors occur\n"); return NULL; @@ -67,6 +69,7 @@ dom_document *load_xml(const char *file, bool willBeModified) readed = read(handle, buffer, 1024); error = dom_xml_parser_parse_chunk(parser, buffer, readed); if (error != DOM_XML_OK) { + dom_node_unref(ret); dom_xml_parser_destroy(parser); fprintf(stderr, "Parsing errors occur\n"); return NULL; @@ -75,12 +78,12 @@ dom_document *load_xml(const char *file, bool willBeModified) error = dom_xml_parser_completed(parser); if (error != DOM_XML_OK) { + dom_node_unref(ret); dom_xml_parser_destroy(parser); fprintf(stderr, "Parsing error when construct DOM\n"); return NULL; } - ret = dom_xml_parser_get_document(parser); dom_xml_parser_destroy(parser); return ret; -- cgit v1.2.3