conmon: Add helper for closing C stdlib FILEs
@@ -59,6 +59,12 @@ static inline void closep(int *fd)
*fd = -1;
}
+static inline void fclosep(FILE **fp) {
+ if (*fp)
+ fclose(*fp);
+ *fp = NULL;
+}
+
static inline void gstring_free_cleanup(GString **string)
{
if (*string)
@@ -67,6 +73,7 @@ static inline void gstring_free_cleanup(GString **string)
#define _cleanup_free_ _cleanup_(freep)
#define _cleanup_close_ _cleanup_(closep)
+#define _cleanup_fclose_ _cleanup_(fclosep)
#define _cleanup_gstring_ _cleanup_(gstring_free_cleanup)
#define BUF_SIZE 256
