提交 a7a8b749 编写于 作者: S Sukrit Bhatnagar 提交者: Erik Skultety

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: NSukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 66a19eaa
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "virnetlink.h" #include "virnetlink.h"
#include "virfile.h" #include "virfile.h"
#include "virerror.h" #include "virerror.h"
#include "viralloc.h"
#include "virlog.h" #include "virlog.h"
#include "virstring.h" #include "virstring.h"
#include "virutil.h" #include "virutil.h"
......
...@@ -98,4 +98,7 @@ void virNetDevIPInfoClear(virNetDevIPInfoPtr ip); ...@@ -98,4 +98,7 @@ void virNetDevIPInfoClear(virNetDevIPInfoPtr ip);
int virNetDevIPInfoAddToDev(const char *ifname, int virNetDevIPInfoAddToDev(const char *ifname,
virNetDevIPInfo const *ipInfo); virNetDevIPInfo const *ipInfo);
VIR_DEFINE_AUTOPTR_FUNC(virNetDevIPAddr, virNetDevIPAddrFree)
VIR_DEFINE_AUTOPTR_FUNC(virNetDevIPRoute, virNetDevIPRouteFree)
#endif /* __VIR_NETDEVIP_H__ */ #endif /* __VIR_NETDEVIP_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册