conmon: Add helper for closing C stdlib FILEs
Signed-off-by: Mrunal Patel <mpatel@redhat.com>
This commit is contained in:
parent
6a24e49b57
commit
8e60251b29
1 changed files with 7 additions and 0 deletions
|
@ -59,6 +59,12 @@ static inline void closep(int *fd)
|
||||||
*fd = -1;
|
*fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void fclosep(FILE **fp) {
|
||||||
|
if (*fp)
|
||||||
|
fclose(*fp);
|
||||||
|
*fp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void gstring_free_cleanup(GString **string)
|
static inline void gstring_free_cleanup(GString **string)
|
||||||
{
|
{
|
||||||
if (*string)
|
if (*string)
|
||||||
|
@ -67,6 +73,7 @@ static inline void gstring_free_cleanup(GString **string)
|
||||||
|
|
||||||
#define _cleanup_free_ _cleanup_(freep)
|
#define _cleanup_free_ _cleanup_(freep)
|
||||||
#define _cleanup_close_ _cleanup_(closep)
|
#define _cleanup_close_ _cleanup_(closep)
|
||||||
|
#define _cleanup_fclose_ _cleanup_(fclosep)
|
||||||
#define _cleanup_gstring_ _cleanup_(gstring_free_cleanup)
|
#define _cleanup_gstring_ _cleanup_(gstring_free_cleanup)
|
||||||
|
|
||||||
#define BUF_SIZE 256
|
#define BUF_SIZE 256
|
||||||
|
|
Loading…
Reference in a new issue