From 3945f3269b3e2763faa1ab22d225ca4dd1856b82 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 14 Jul 2022 20:53:09 +0200 Subject: Adding upstream version 1.0. Signed-off-by: Daniel Baumann --- src/nvme/cleanup.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/nvme/cleanup.h (limited to 'src/nvme/cleanup.h') diff --git a/src/nvme/cleanup.h b/src/nvme/cleanup.h new file mode 100644 index 0000000..89a4984 --- /dev/null +++ b/src/nvme/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