Commit 6ab7e301 authored by Frederik Carlier's avatar Frederik Carlier Committed by Nikias Bassen

Move libxml cleanup code to a plist_cleanup method

parent 275cfcd5
...@@ -111,6 +111,19 @@ extern "C" ...@@ -111,6 +111,19 @@ extern "C"
} plist_type; } plist_type;
/********************************************
* *
* Library Initialization & Cleanup *
* *
********************************************/
/**
* Frees memory used globally by listplist, in
* particular the libxml parser
*/
void plist_cleanup(void);
/******************************************** /********************************************
* * * *
* Creation & Destruction * * Creation & Destruction *
......
...@@ -31,6 +31,24 @@ ...@@ -31,6 +31,24 @@
#include <node.h> #include <node.h>
#include <node_iterator.h> #include <node_iterator.h>
#include <libxml/encoding.h>
#include <libxml/dict.h>
#include <libxml/xmlerror.h>
#include <libxml/globals.h>
#include <libxml/threads.h>
#include <libxml/xmlmemory.h>
void plist_cleanup(void)
{
/* free memory from parser initialization */
xmlCleanupCharEncodingHandlers();
xmlDictCleanup();
xmlResetLastError();
xmlCleanupGlobals();
xmlCleanupThreads();
xmlCleanupMemory();
}
plist_t plist_new_node(plist_data_t data) plist_t plist_new_node(plist_data_t data)
{ {
return (plist_t) node_create(NULL, data); return (plist_t) node_create(NULL, data);
......
...@@ -573,15 +573,6 @@ PLIST_API void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length) ...@@ -573,15 +573,6 @@ PLIST_API void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length)
tmp = NULL; tmp = NULL;
} }
xmlFreeDoc(plist_doc); xmlFreeDoc(plist_doc);
/* free memory from parser initialization */
xmlCleanupCharEncodingHandlers();
xmlDictCleanup();
xmlResetLastError();
xmlCleanupGlobals();
xmlCleanupThreads();
xmlCleanupMemory();
} }
static xmlParserInputPtr plist_xml_external_entity_loader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt) static xmlParserInputPtr plist_xml_external_entity_loader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
...@@ -602,12 +593,4 @@ PLIST_API void plist_from_xml(const char *plist_xml, uint32_t length, plist_t * ...@@ -602,12 +593,4 @@ PLIST_API void plist_from_xml(const char *plist_xml, uint32_t length, plist_t *
xml_to_node(root_node, plist); xml_to_node(root_node, plist);
xmlFreeDoc(plist_doc); xmlFreeDoc(plist_doc);
} }
/* free memory from parser initialization */
xmlCleanupCharEncodingHandlers();
xmlDictCleanup();
xmlResetLastError();
xmlCleanupGlobals();
xmlCleanupThreads();
xmlCleanupMemory();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment