]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: bitmap: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
authorSukrit Bhatnagar <skrtbhtngr@gmail.com>
Fri, 13 Jul 2018 17:55:00 +0000 (23:25 +0530)
committerErik Skultety <eskultet@redhat.com>
Sat, 14 Jul 2018 15:01:30 +0000 (17:01 +0200)
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 virBitmapPtr is declared using
VIR_AUTOPTR, the function virBitmapFree 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/virbitmap.c
src/util/virbitmap.h

index 0cc5292d8c4e19dc45d95b69e56f704b0e6abccc..ef18dad255aa14537c0232664bc31058cab087b6 100644 (file)
@@ -31,7 +31,6 @@
 #include <sys/types.h>
 
 #include "virbitmap.h"
-#include "viralloc.h"
 #include "virbuffer.h"
 #include "c-ctype.h"
 #include "count-one-bits.h"
index 2464814055de9d74edc7b834a7817d5ae5d3901a..312e7e293375a13c312983d517391d9c653f3e82 100644 (file)
@@ -25,6 +25,7 @@
 # define __BITMAP_H__
 
 # include "internal.h"
+# include "viralloc.h"
 
 # include <sys/types.h>
 
@@ -155,4 +156,6 @@ void virBitmapSubtract(virBitmapPtr a, virBitmapPtr b)
 
 void virBitmapShrink(virBitmapPtr map, size_t b);
 
+VIR_DEFINE_AUTOPTR_FUNC(virBitmap, virBitmapFree)
+
 #endif