From c16a1cea13c70e9c40a8db82d561e71bd04f404f Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 16 Nov 2014 16:51:30 -0500 Subject: Reorg a bit, introduce a control struct --- util.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 util.h (limited to 'util.h') diff --git a/util.h b/util.h new file mode 100644 index 0000000..6d50426 --- /dev/null +++ b/util.h @@ -0,0 +1,14 @@ +#ifndef _UTIL_H +#define _UTIL_H + +#include +#include +#include + +static inline void freep(void *p) { free(*(void **)p); } +static inline void fclosep(FILE **p) { if (*p) fclose(*p); } +static inline void globfreep(glob_t *p) { globfree(p); } +#define _cleanup_(x) __attribute__((cleanup(x))) +#define _cleanup_free_ _cleanup_(freep) + +#endif /* _UTIL_H */ -- cgit v1.2.3-54-g00ecf