render / rpms / libvirt

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