diff options
| -rw-r--r-- | include/plist/plist.h | 13 | ||||
| -rw-r--r-- | src/plist.c | 18 | ||||
| -rw-r--r-- | src/xplist.c | 17 | 
3 files changed, 31 insertions, 17 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h index c66545a..acd1c4d 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h @@ -113,6 +113,19 @@ extern "C"      /********************************************       *                                          * +     *     Library Initialization & Cleanup     * +     *                                          * +     ********************************************/ + +    /** +     * Frees memory used globally by listplist, in +     * particular the libxml parser +     */ +     +    void plist_cleanup(void); +     +    /******************************************** +     *                                          *       *          Creation & Destruction          *       *                                          *       ********************************************/ diff --git a/src/plist.c b/src/plist.c index d40b946..569251b 100644 --- a/src/plist.c +++ b/src/plist.c @@ -31,6 +31,24 @@  #include <node.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)  {      return (plist_t) node_create(NULL, data); diff --git a/src/xplist.c b/src/xplist.c index 09c1a11..e0a76da 100644 --- a/src/xplist.c +++ b/src/xplist.c @@ -573,15 +573,6 @@ PLIST_API void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length)  	tmp = NULL;      }      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) @@ -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);          xmlFreeDoc(plist_doc);      } - -    /* free memory from parser initialization */ -    xmlCleanupCharEncodingHandlers(); -    xmlDictCleanup(); -    xmlResetLastError(); -    xmlCleanupGlobals(); -    xmlCleanupThreads(); -    xmlCleanupMemory();  }  | 
