From 5ce70e5bcd62e89b52485961c3699312ee4a7e0e Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 31 Dec 2013 22:35:54 -0500 Subject: Introduce cleanup functions for cap_free Unfortunately a different cleanup function is necessary per type, because cap_t** and char** are incompatible with void**. --- src/shared/capability.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/shared/capability.h') diff --git a/src/shared/capability.h b/src/shared/capability.h index 59469e56cb..64f86410ab 100644 --- a/src/shared/capability.h +++ b/src/shared/capability.h @@ -23,8 +23,20 @@ #include #include +#include + +#include "util.h" unsigned long cap_last_cap(void); int have_effective_cap(int value); int capability_bounding_set_drop(uint64_t drop, bool right_now); int capability_bounding_set_drop_usermode(uint64_t drop); + +DEFINE_TRIVIAL_CLEANUP_FUNC(cap_t, cap_free); +#define _cleanup_cap_free_ _cleanup_(cap_freep) + +static inline void cap_free_charpp(char **p) { + if (*p) + cap_free(*p); +} +#define _cleanup_cap_free_charp_ _cleanup_(cap_free_charpp) -- cgit v1.2.3-54-g00ecf