diff options
author | Thomas Haller <thaller@redhat.com> | 2023-12-01 16:28:59 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-12-01 16:34:07 (GMT) |
commit | 72762b2006cd4a6c630989600e11c98b63d0fa31 (patch) | |
tree | ffd0b919c2a47d08268b08bf9a2f9eac21e44661 /include | |
parent | a70f789a79d734979af8610dadb3e2ee42e6b6ee (diff) | |
download | libnl-72762b2006cd4a6c630989600e11c98b63d0fa31.zip libnl-72762b2006cd4a6c630989600e11c98b63d0fa31.tar.gz libnl-72762b2006cd4a6c630989600e11c98b63d0fa31.tar.bz2 |
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`.
Diffstat (limited to 'include')
-rw-r--r-- | include/base/nl-base-utils.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/base/nl-base-utils.h b/include/base/nl-base-utils.h index 11986e9..03d568e 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); |