conmon: Add helper for closing C stdlib FILEs

Signed-off-by: Mrunal Patel <mpatel@redhat.com>
This commit is contained in:
Mrunal Patel 2017-05-22 19:00:02 -07:00 committed by Mrunal Patel
parent 6a24e49b57
commit 8e60251b29

View file

@ -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