Small cleanup helper to dispose xmlChar* buffers.
---
src/cleanup.c | 9 +++++++++
src/guestfs-internal-frontend.h | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/src/cleanup.c b/src/cleanup.c
index 1aa3051..6c4558c 100644
--- a/src/cleanup.c
+++ b/src/cleanup.c
@@ -106,6 +106,15 @@ guestfs_int_cleanup_unlink_free (char **ptr)
}
void
+guestfs_int_cleanup_xmlFree (void *ptr)
+{
+ xmlChar *buf = * (xmlChar **) ptr;
+
+ if (buf)
+ xmlFree (buf);
+}
+
+void
guestfs_int_cleanup_xmlBufferFree (void *ptr)
{
xmlBufferPtr xb = * (xmlBufferPtr *) ptr;
diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h
index d1de76d..8689009 100644
--- a/src/guestfs-internal-frontend.h
+++ b/src/guestfs-internal-frontend.h
@@ -43,6 +43,8 @@
__attribute__((cleanup(guestfs_int_cleanup_hash_free)))
#define CLEANUP_UNLINK_FREE \
__attribute__((cleanup(guestfs_int_cleanup_unlink_free)))
+#define CLEANUP_XMLFREE \
+ __attribute__((cleanup(guestfs_int_cleanup_xmlFree)))
#define CLEANUP_XMLBUFFERFREE \
__attribute__((cleanup(guestfs_int_cleanup_xmlBufferFree)))
#define CLEANUP_XMLFREEDOC \
@@ -62,6 +64,7 @@
#define CLEANUP_FREE_STRING_LIST
#define CLEANUP_HASH_FREE
#define CLEANUP_UNLINK_FREE
+#define CLEANUP_XMLFREE
#define CLEANUP_XMLBUFFERFREE
#define CLEANUP_XMLFREEDOC
#define CLEANUP_XMLFREEURI
@@ -109,6 +112,7 @@ extern void guestfs_int_cleanup_free (void *ptr);
extern void guestfs_int_cleanup_free_string_list (char ***ptr);
extern void guestfs_int_cleanup_hash_free (void *ptr);
extern void guestfs_int_cleanup_unlink_free (char **ptr);
+extern void guestfs_int_cleanup_xmlFree (void *ptr);
extern void guestfs_int_cleanup_xmlBufferFree (void *ptr);
extern void guestfs_int_cleanup_xmlFreeDoc (void *ptr);
extern void guestfs_int_cleanup_xmlFreeURI (void *ptr);
--
2.7.4