summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-12-01 17:28:59 +0100
committerThomas Haller <thaller@redhat.com>2023-12-01 17:34:07 +0100
commit72762b2006cd4a6c630989600e11c98b63d0fa31 (patch)
treeffd0b919c2a47d08268b08bf9a2f9eac21e44661
parenta70f789a79d734979af8610dadb3e2ee42e6b6ee (diff)
downloadlibnl-72762b2006cd4a6c630989600e11c98b63d0fa31.tar.gz
base: add _NL_AUTO_DEFINE_FCN_INDIRECT0() macro
This is useful for a very special case. For a cleanup macro that calls rtnl_act_put_all(). In that case, we have a auto variable `struct rtnl_act *head`, but the cleanup function expects as argument `&head`.
-rw-r--r--include/base/nl-base-utils.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/base/nl-base-utils.h b/include/base/nl-base-utils.h
index 11986e93..03d568e2 100644
--- a/include/base/nl-base-utils.h
+++ b/include/base/nl-base-utils.h
@@ -734,6 +734,14 @@ static inline char *_nl_inet_ntop_dup(int addr_family, const void *addr)
} \
struct _nl_dummy_for_tailing_semicolon
+#define _NL_AUTO_DEFINE_FCN_INDIRECT0(CastType, name, func) \
+ static inline void name(CastType *v) \
+ { \
+ if (*v) \
+ func(v); \
+ } \
+ struct _nl_dummy_for_tailing_semicolon
+
#define _nl_auto_free _nl_auto(_nl_auto_free_fcn)
_NL_AUTO_DEFINE_FCN_VOID0(void *, _nl_auto_free_fcn, free);