summaryrefslogtreecommitdiff
path: root/test/lib/testobject.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-09-29 01:12:08 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-09-29 01:12:08 +0000
commit7eb2967d9be33c58e7927b7973c9dc50c9f71a62 (patch)
tree4d9bc299e105ba0bd6af4f7a9b940feba117bb22 /test/lib/testobject.c
parent6b1aeb6465f339bfbc7be33b1ecab3f235adbe7f (diff)
downloadlibdom-7eb2967d9be33c58e7927b7973c9dc50c9f71a62.tar.gz
libdom-7eb2967d9be33c58e7927b7973c9dc50c9f71a62.tar.bz2
Add finalisation method to libxml-libdom.
Ensure testcases clean up after themselves by calling xml_dom_binding_finalise() svn path=/trunk/dom/; revision=3605
Diffstat (limited to 'test/lib/testobject.c')
-rw-r--r--test/lib/testobject.c13
1 files changed, 11 insertions, 2 deletions
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();
+}