From 2fe1b73a5dbbfd79c3a1a8c48747a68846785e3b Mon Sep 17 00:00:00 2001
Message-Id: <2fe1b73a5dbbfd79c3a1a8c48747a68846785e3b@dist-git>
From: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Date: Wed, 5 Jun 2019 11:33:27 +0200
Subject: [PATCH] util: bitmap: 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 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>
(cherry picked from commit a3c915e662f8c25cac683e20bbc419b497555e13)
https://bugzilla.redhat.com/show_bug.cgi?id=1716943
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <fcbb5d4453100962a2fc83e486da799012eec675.1559727075.git.mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
---
src/util/virbitmap.c | 1 -
src/util/virbitmap.h | 3 +++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 0cc5292d8c..ef18dad255 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -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"
diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
index 2464814055..312e7e2933 100644
--- a/src/util/virbitmap.h
+++ b/src/util/virbitmap.h
@@ -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
--
2.22.0