From: Sukrit Bhatnagar Date: Sat, 28 Jul 2018 18:01:37 +0000 (+0530) Subject: util: netlink: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC X-Git-Tag: v4.7.0-rc1~296 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4acb7887e46693fb119cdd154545c149d3427a86;p=thirdparty%2Flibvirt.git util: netlink: 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 a variable of type virNetlinkHandle * is declared using VIR_AUTOPTR, the function virNetlinkFree will be run automatically on it when it goes out of scope. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index fa1ba3e2a1..2702c12d24 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -72,6 +72,8 @@ typedef struct nl_handle virNetlinkHandle; typedef struct nl_sock virNetlinkHandle; # endif +VIR_DEFINE_AUTOPTR_FUNC(virNetlinkHandle, virNetlinkFree) + typedef struct _virNetlinkEventSrvPrivate virNetlinkEventSrvPrivate; typedef virNetlinkEventSrvPrivate *virNetlinkEventSrvPrivatePtr; struct _virNetlinkEventSrvPrivate {