From e6fdfd4c4c753fe3a06edc4ae3b767c57c10d3f7 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Sat, 11 Jul 2020 18:07:27 +0200 Subject: Flesh out the new command a bit more --- shared/utils.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'shared/utils.h') diff --git a/shared/utils.h b/shared/utils.h index 9404323..c47f9a5 100644 --- a/shared/utils.h +++ b/shared/utils.h @@ -10,6 +10,7 @@ #include #include #include +#include extern unsigned debug_mask; @@ -127,4 +128,18 @@ static inline bool strcaseeq(const char *a, const char *b) #define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d)) +#define _cleanup_(x) __attribute__((cleanup(x))) + +static inline void closep(int *fd) +{ + if (*fd && *fd >= 0) + close(*fd); +} +#define _cleanup_close_ _cleanup_(closep) + +static inline void freep(void *p) { + xfree(*(void**)p); +} +#define _cleanup_free_ _cleanup_(freep) + #endif -- cgit v1.2.3