]> xenbits.xensource.com Git - libvirt.git/commit
util: netlink: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
authorSukrit Bhatnagar <skrtbhtngr@gmail.com>
Thu, 9 Aug 2018 04:12:10 +0000 (09:42 +0530)
committerErik Skultety <eskultet@redhat.com>
Mon, 13 Aug 2018 18:03:53 +0000 (20:03 +0200)
commitf7d0663d491eddf576166d1ab78668b3e7019ac8
treec160420f48bef746fbc45fc54e87f215f9d7cd71
parentcbc1326b21d3997f217bff4b4a1fede7c81f66ff
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.

This commit also typedefs virNetlinkMsg to struct nl_msg type for use
with the cleanup macros.

When a variable of type virNetlinkMsg * is declared using VIR_AUTOPTR,
the function nlmsg_free will be run automatically on it when it
goes out of scope.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/util/virnetlink.c
src/util/virnetlink.h