---
src/cleanup.c | 9 +++++++++
src/guestfs-internal-frontend.h | 3 +++
2 files changed, 12 insertions(+)
diff --git a/src/cleanup.c b/src/cleanup.c
index 86bb547..4e1a7f9 100644
--- a/src/cleanup.c
+++ b/src/cleanup.c
@@ -122,3 +122,12 @@ guestfs___cleanup_xmlXPathFreeObject (void *ptr)
if (obj)
xmlXPathFreeObject (obj);
}
+
+void
+guestfs___cleanup_fclose (void *ptr)
+{
+ FILE *f = * (FILE **) ptr;
+
+ if (f)
+ fclose (f);
+}
diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h
index 6bf0a94..acd7be5 100644
--- a/src/guestfs-internal-frontend.h
+++ b/src/guestfs-internal-frontend.h
@@ -55,6 +55,7 @@
__attribute__((cleanup(guestfs___cleanup_xmlXPathFreeContext)))
#define CLEANUP_XMLXPATHFREEOBJECT \
__attribute__((cleanup(guestfs___cleanup_xmlXPathFreeObject)))
+#define CLEANUP_FCLOSE __attribute__((cleanup(guestfs___cleanup_fclose)))
#else
#define CLEANUP_FREE
#define CLEANUP_FREE_STRING_LIST
@@ -66,6 +67,7 @@
#define CLEANUP_XMLFREETEXTWRITER
#define CLEANUP_XMLXPATHFREECONTEXT
#define CLEANUP_XMLXPATHFREEOBJECT
+#define CLEANUP_FCLOSE
#endif
/* NB: At some point we will stop exporting these safe_* allocation
@@ -115,6 +117,7 @@ extern void guestfs___cleanup_xmlFreeURI (void *ptr);
extern void guestfs___cleanup_xmlFreeTextWriter (void *ptr);
extern void guestfs___cleanup_xmlXPathFreeContext (void *ptr);
extern void guestfs___cleanup_xmlXPathFreeObject (void *ptr);
+extern void guestfs___cleanup_fclose (void *ptr);
/* These are in a separate header so the header can be generated.
* Don't include the following file directly:
--
1.9.3