From 5b7ddc4bd2dcdde201ffa2681ede9a0a029bad96 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 2 Jul 2021 22:47:46 +0200 Subject: Adding upstream version 1.14. Signed-off-by: Daniel Baumann --- util/cleanup.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 util/cleanup.h (limited to 'util/cleanup.h') diff --git a/util/cleanup.h b/util/cleanup.h new file mode 100644 index 0000000..89a4984 --- /dev/null +++ b/util/cleanup.h @@ -0,0 +1,18 @@ +#ifndef __CLEANUP_H +#define __CLEANUP_H + +#define __cleanup__(fn) __attribute__((cleanup(fn))) + +#define DECLARE_CLEANUP_FUNC(name, type) \ + void name(type *__p) + +#define DEFINE_CLEANUP_FUNC(name, type, free_fn)\ +DECLARE_CLEANUP_FUNC(name, type) \ +{ \ + if (*__p) \ + free_fn(*__p); \ +} + +DECLARE_CLEANUP_FUNC(cleanup_charp, char *); + +#endif -- cgit v1.2.3