On Sat, Jul 28, 2018 at 11:31:29PM +0530, Sukrit Bhatnagar wrote: > 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 virNetlinkCallbackDataPtr is declared using > VIR_AUTOPTR, the function virNetlinkCallbackDataFree will be run > automatically on it when it goes out of scope. > > This commit also adds an intermediate typedef for virNetlinkCallbackData > type for use with the cleanup macros. > > Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@xxxxxxxxx> > --- > src/util/virnetdevmacvlan.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c > index fb41bf9..91c6244 100644 > --- a/src/util/virnetdevmacvlan.c > +++ b/src/util/virnetdevmacvlan.c > @@ -576,7 +576,7 @@ static const uint32_t modeMap[VIR_NETDEV_MACVLAN_MODE_LAST] = { > }; > > /* Struct to hold the state and configuration of a 802.1qbg port */ > -struct virNetlinkCallbackData { > +struct _virNetlinkCallbackData { > char *cr_ifname; > virNetDevVPortProfilePtr virtPortProfile; > virMacAddr macaddress; > @@ -587,7 +587,8 @@ struct virNetlinkCallbackData { > unsigned int linkState; > }; > > -typedef struct virNetlinkCallbackData *virNetlinkCallbackDataPtr; > +typedef struct _virNetlinkCallbackData virNetlinkCallbackData; > +typedef virNetlinkCallbackData *virNetlinkCallbackDataPtr; > > # define INSTANCE_STRLEN 36 > > @@ -870,6 +871,8 @@ virNetlinkCallbackDataFree(virNetlinkCallbackDataPtr calld) > VIR_FREE(calld); > } > > +VIR_DEFINE_AUTOPTR_FUNC(virNetlinkCallbackData, virNetlinkCallbackDataFree) I believe we can add this once we have a better use case, right now, we don't, so this patch can be dropped. Erik -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list