Blame SOURCES/libvirt-util-bitmap-define-cleanup-function-using-VIR_DEFINE_AUTOPTR_FUNC.patch

c313de
From 2fe1b73a5dbbfd79c3a1a8c48747a68846785e3b Mon Sep 17 00:00:00 2001
c313de
Message-Id: <2fe1b73a5dbbfd79c3a1a8c48747a68846785e3b@dist-git>
c313de
From: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
c313de
Date: Wed, 5 Jun 2019 11:33:27 +0200
c313de
Subject: [PATCH] util: bitmap: define cleanup function using
c313de
 VIR_DEFINE_AUTOPTR_FUNC
c313de
c313de
Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
c313de
src/util/viralloc.h, define a new wrapper around an existing
c313de
cleanup function which will be called when a variable declared
c313de
with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
c313de
viralloc.h include, since that has moved from the source module into the
c313de
header.
c313de
c313de
When a variable of type virBitmapPtr is declared using
c313de
VIR_AUTOPTR, the function virBitmapFree will be run
c313de
automatically on it when it goes out of scope.
c313de
c313de
Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
c313de
Reviewed-by: Erik Skultety <eskultet@redhat.com>
c313de
(cherry picked from commit a3c915e662f8c25cac683e20bbc419b497555e13)
c313de
c313de
https://bugzilla.redhat.com/show_bug.cgi?id=1716943
c313de
c313de
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c313de
Message-Id: <fcbb5d4453100962a2fc83e486da799012eec675.1559727075.git.mprivozn@redhat.com>
c313de
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
c313de
---
c313de
 src/util/virbitmap.c | 1 -
c313de
 src/util/virbitmap.h | 3 +++
c313de
 2 files changed, 3 insertions(+), 1 deletion(-)
c313de
c313de
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
c313de
index 0cc5292d8c..ef18dad255 100644
c313de
--- a/src/util/virbitmap.c
c313de
+++ b/src/util/virbitmap.c
c313de
@@ -31,7 +31,6 @@
c313de
 #include <sys/types.h>
c313de
 
c313de
 #include "virbitmap.h"
c313de
-#include "viralloc.h"
c313de
 #include "virbuffer.h"
c313de
 #include "c-ctype.h"
c313de
 #include "count-one-bits.h"
c313de
diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
c313de
index 2464814055..312e7e2933 100644
c313de
--- a/src/util/virbitmap.h
c313de
+++ b/src/util/virbitmap.h
c313de
@@ -25,6 +25,7 @@
c313de
 # define __BITMAP_H__
c313de
 
c313de
 # include "internal.h"
c313de
+# include "viralloc.h"
c313de
 
c313de
 # include <sys/types.h>
c313de
 
c313de
@@ -155,4 +156,6 @@ void virBitmapSubtract(virBitmapPtr a, virBitmapPtr b)
c313de
 
c313de
 void virBitmapShrink(virBitmapPtr map, size_t b);
c313de
 
c313de
+VIR_DEFINE_AUTOPTR_FUNC(virBitmap, virBitmapFree)
c313de
+
c313de
 #endif
c313de
-- 
c313de
2.22.0
c313de