diff options
-rw-r--r-- | bindings/xml/xmlbinding.c | 18 | ||||
-rw-r--r-- | bindings/xml/xmlbinding.h | 3 | ||||
-rw-r--r-- | test/lib/testobject.c | 13 |
3 files changed, 32 insertions, 2 deletions
diff --git a/bindings/xml/xmlbinding.c b/bindings/xml/xmlbinding.c index 7e2814e..9c0d832 100644 --- a/bindings/xml/xmlbinding.c +++ b/bindings/xml/xmlbinding.c @@ -396,3 +396,21 @@ xml_error xml_dom_binding_initialise(xml_alloc alloc, void *pw) return XML_OK; } +/** + * Finalise the XML DOM binding + * + * \return XML_OK on success. + */ +xml_error xml_dom_binding_finalise(void) +{ + dom_exception err; + + err = dom_finalise(); + if (err != DOM_NO_ERR) { + /** \todo Do something about it */ + } + + return XML_OK; +} + + diff --git a/bindings/xml/xmlbinding.h b/bindings/xml/xmlbinding.h index b7f9002..9b21b9e 100644 --- a/bindings/xml/xmlbinding.h +++ b/bindings/xml/xmlbinding.h @@ -14,4 +14,7 @@ /* Initialise the XML DOM binding */ xml_error xml_dom_binding_initialise(xml_alloc alloc, void *pw); +/* Finalise the XML DOM binding */ +xml_error xml_dom_binding_finalise(void); + #endif diff --git a/test/lib/testobject.c b/test/lib/testobject.c index e9d3d06..17e5233 100644 --- a/test/lib/testobject.c +++ b/test/lib/testobject.c @@ -15,16 +15,18 @@ #include "testobject.h" #include "utils.h" +static bool xml_parser_initialised; + struct TestObject { xml_parser *parser; struct dom_document *doc; }; +static void test_object_cleanup(void); + TestObject *test_object_create(int argc, char **argv, const char *uri, bool will_be_modified) { - static bool xml_parser_initialised; - char fnbuf[1024]; #define CHUNK_SIZE 4096 uint8_t buf[CHUNK_SIZE]; @@ -42,6 +44,8 @@ TestObject *test_object_create(int argc, char **argv, if (xml_parser_initialised == false) { assert(xml_dom_binding_initialise(myrealloc, NULL) == XML_OK); + atexit(test_object_cleanup); + xml_parser_initialised = true; } @@ -113,4 +117,9 @@ const char *test_object_get_mimetype(TestObject *obj) return "text/xml"; } +void test_object_cleanup(void) +{ + if (xml_parser_initialised) + xml_dom_binding_finalise(); +} |