render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From 25ceaef5ff5e392dace991db3e737dbdb50a6bba Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <25ceaef5ff5e392dace991db3e737dbdb50a6bba@dist-git>
c480ed
From: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
c480ed
Date: Fri, 21 Jun 2019 09:26:02 +0200
c480ed
Subject: [PATCH] util: json: define cleanup function using
c480ed
 VIR_DEFINE_AUTOPTR_FUNC
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
c480ed
src/util/viralloc.h, define a new wrapper around an existing
c480ed
cleanup function which will be called when a variable declared
c480ed
with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
c480ed
viralloc.h include, since that has moved from the source module into the
c480ed
header.
c480ed
c480ed
When a variable of type virJSONValuePtr is declared using
c480ed
VIR_AUTOPTR, the function virJSONValueFree will be run
c480ed
automatically on it when it goes out of scope.
c480ed
c480ed
Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
c480ed
Reviewed-by: Erik Skultety <eskultet@redhat.com>
c480ed
(cherry picked from commit b5b5cdd69ca1c954635f9f6dda05d6b15b01cc8a)
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Message-Id: <4dd72d7d93725d77a2bd89fbd890fe3d774f29d2.1561068591.git.jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/util/virjson.c | 1 -
c480ed
 src/util/virjson.h | 3 +++
c480ed
 2 files changed, 3 insertions(+), 1 deletion(-)
c480ed
c480ed
diff --git a/src/util/virjson.c b/src/util/virjson.c
c480ed
index 0559d40b64..92f3994e92 100644
c480ed
--- a/src/util/virjson.c
c480ed
+++ b/src/util/virjson.c
c480ed
@@ -24,7 +24,6 @@
c480ed
 #include <config.h>
c480ed
 
c480ed
 #include "virjson.h"
c480ed
-#include "viralloc.h"
c480ed
 #include "virerror.h"
c480ed
 #include "virlog.h"
c480ed
 #include "virstring.h"
c480ed
diff --git a/src/util/virjson.h b/src/util/virjson.h
c480ed
index e4a82bdbc8..75f7f17b44 100644
c480ed
--- a/src/util/virjson.h
c480ed
+++ b/src/util/virjson.h
c480ed
@@ -26,6 +26,7 @@
c480ed
 
c480ed
 # include "internal.h"
c480ed
 # include "virbitmap.h"
c480ed
+# include "viralloc.h"
c480ed
 
c480ed
 # include <stdarg.h>
c480ed
 
c480ed
@@ -156,4 +157,6 @@ char *virJSONStringReformat(const char *jsonstr, bool pretty);
c480ed
 
c480ed
 virJSONValuePtr virJSONValueObjectDeflatten(virJSONValuePtr json);
c480ed
 
c480ed
+VIR_DEFINE_AUTOPTR_FUNC(virJSONValue, virJSONValueFree)
c480ed
+
c480ed
 #endif /* __VIR_JSON_H_ */
c480ed
-- 
c480ed
2.22.0
c480ed