From a7a8b7492891a0c8f96c9d6dc99efec916f24ccd Mon Sep 17 00:00:00 2001 From: Sukrit Bhatnagar Date: Sat, 28 Jul 2018 23:31:26 +0530 Subject: [PATCH] util: netdevip: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in src/util/viralloc.h, define a new wrapper around an existing cleanup function which will be called when a variable declared with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant viralloc.h include, since that has moved from the source module into the header. When variables of type virNetDevIPAddrPtr and virNetDevIPRoutePtr are declared using VIR_AUTOPTR, the functions virNetDevIPAddrFree and virNetDevIPRouteFree, respectively, will be run automatically on them when they go out of scope. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virnetdevip.c | 1 - src/util/virnetdevip.h | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c index 7197d07d60..fdb0b74b37 100644 --- a/src/util/virnetdevip.c +++ b/src/util/virnetdevip.c @@ -27,7 +27,6 @@ #include "virnetlink.h" #include "virfile.h" #include "virerror.h" -#include "viralloc.h" #include "virlog.h" #include "virstring.h" #include "virutil.h" diff --git a/src/util/virnetdevip.h b/src/util/virnetdevip.h index dfc978d815..5608c37143 100644 --- a/src/util/virnetdevip.h +++ b/src/util/virnetdevip.h @@ -98,4 +98,7 @@ void virNetDevIPInfoClear(virNetDevIPInfoPtr ip); int virNetDevIPInfoAddToDev(const char *ifname, virNetDevIPInfo const *ipInfo); +VIR_DEFINE_AUTOPTR_FUNC(virNetDevIPAddr, virNetDevIPAddrFree) +VIR_DEFINE_AUTOPTR_FUNC(virNetDevIPRoute, virNetDevIPRouteFree) + #endif /* __VIR_NETDEVIP_H__ */ -- 2.47.2