diff options
| author | 2016-03-26 15:30:28 +0100 | |
|---|---|---|
| committer | 2016-04-20 14:18:46 +0200 | |
| commit | 6ab7e301f1854fd18891ddfeaa64e7485be990ba (patch) | |
| tree | b895af9cd1f73235f85bc1b67d450e2fbd590d6e /src | |
| parent | 275cfcd5ac317185c9f3d8156c357df5f8155c37 (diff) | |
| download | libplist-6ab7e301f1854fd18891ddfeaa64e7485be990ba.tar.gz libplist-6ab7e301f1854fd18891ddfeaa64e7485be990ba.tar.bz2 | |
Move libxml cleanup code to a plist_cleanup method
Diffstat (limited to 'src')
| -rw-r--r-- | src/plist.c | 18 | ||||
| -rw-r--r-- | src/xplist.c | 17 |
2 files changed, 18 insertions, 17 deletions
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 @@ | |||
| 31 | #include <node.h> | 31 | #include <node.h> |
| 32 | #include <node_iterator.h> | 32 | #include <node_iterator.h> |
| 33 | 33 | ||
| 34 | #include <libxml/encoding.h> | ||
| 35 | #include <libxml/dict.h> | ||
| 36 | #include <libxml/xmlerror.h> | ||
| 37 | #include <libxml/globals.h> | ||
| 38 | #include <libxml/threads.h> | ||
| 39 | #include <libxml/xmlmemory.h> | ||
| 40 | |||
| 41 | void plist_cleanup(void) | ||
| 42 | { | ||
| 43 | /* free memory from parser initialization */ | ||
| 44 | xmlCleanupCharEncodingHandlers(); | ||
| 45 | xmlDictCleanup(); | ||
| 46 | xmlResetLastError(); | ||
| 47 | xmlCleanupGlobals(); | ||
| 48 | xmlCleanupThreads(); | ||
| 49 | xmlCleanupMemory(); | ||
| 50 | } | ||
| 51 | |||
| 34 | plist_t plist_new_node(plist_data_t data) | 52 | plist_t plist_new_node(plist_data_t data) |
| 35 | { | 53 | { |
| 36 | return (plist_t) node_create(NULL, data); | 54 | 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) | |||
| 573 | tmp = NULL; | 573 | tmp = NULL; |
| 574 | } | 574 | } |
| 575 | xmlFreeDoc(plist_doc); | 575 | xmlFreeDoc(plist_doc); |
| 576 | |||
| 577 | |||
| 578 | /* free memory from parser initialization */ | ||
| 579 | xmlCleanupCharEncodingHandlers(); | ||
| 580 | xmlDictCleanup(); | ||
| 581 | xmlResetLastError(); | ||
| 582 | xmlCleanupGlobals(); | ||
| 583 | xmlCleanupThreads(); | ||
| 584 | xmlCleanupMemory(); | ||
| 585 | } | 576 | } |
| 586 | 577 | ||
| 587 | static xmlParserInputPtr plist_xml_external_entity_loader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt) | 578 | 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 | xml_to_node(root_node, plist); | 593 | xml_to_node(root_node, plist); |
| 603 | xmlFreeDoc(plist_doc); | 594 | xmlFreeDoc(plist_doc); |
| 604 | } | 595 | } |
| 605 | |||
| 606 | /* free memory from parser initialization */ | ||
| 607 | xmlCleanupCharEncodingHandlers(); | ||
| 608 | xmlDictCleanup(); | ||
| 609 | xmlResetLastError(); | ||
| 610 | xmlCleanupGlobals(); | ||
| 611 | xmlCleanupThreads(); | ||
| 612 | xmlCleanupMemory(); | ||
| 613 | } | 596 | } |
