|
|
c313de |
From 25ceaef5ff5e392dace991db3e737dbdb50a6bba Mon Sep 17 00:00:00 2001
|
|
|
c313de |
Message-Id: <25ceaef5ff5e392dace991db3e737dbdb50a6bba@dist-git>
|
|
|
c313de |
From: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
|
|
|
c313de |
Date: Fri, 21 Jun 2019 09:26:02 +0200
|
|
|
c313de |
Subject: [PATCH] util: json: define cleanup function using
|
|
|
c313de |
VIR_DEFINE_AUTOPTR_FUNC
|
|
|
c313de |
MIME-Version: 1.0
|
|
|
c313de |
Content-Type: text/plain; charset=UTF-8
|
|
|
c313de |
Content-Transfer-Encoding: 8bit
|
|
|
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 virJSONValuePtr is declared using
|
|
|
c313de |
VIR_AUTOPTR, the function virJSONValueFree 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 b5b5cdd69ca1c954635f9f6dda05d6b15b01cc8a)
|
|
|
c313de |
|
|
|
c313de |
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
|
|
|
c313de |
|
|
|
c313de |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c313de |
Message-Id: <4dd72d7d93725d77a2bd89fbd890fe3d774f29d2.1561068591.git.jdenemar@redhat.com>
|
|
|
c313de |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c313de |
---
|
|
|
c313de |
src/util/virjson.c | 1 -
|
|
|
c313de |
src/util/virjson.h | 3 +++
|
|
|
c313de |
2 files changed, 3 insertions(+), 1 deletion(-)
|
|
|
c313de |
|
|
|
c313de |
diff --git a/src/util/virjson.c b/src/util/virjson.c
|
|
|
c313de |
index 0559d40b64..92f3994e92 100644
|
|
|
c313de |
--- a/src/util/virjson.c
|
|
|
c313de |
+++ b/src/util/virjson.c
|
|
|
c313de |
@@ -24,7 +24,6 @@
|
|
|
c313de |
#include <config.h>
|
|
|
c313de |
|
|
|
c313de |
#include "virjson.h"
|
|
|
c313de |
-#include "viralloc.h"
|
|
|
c313de |
#include "virerror.h"
|
|
|
c313de |
#include "virlog.h"
|
|
|
c313de |
#include "virstring.h"
|
|
|
c313de |
diff --git a/src/util/virjson.h b/src/util/virjson.h
|
|
|
c313de |
index e4a82bdbc8..75f7f17b44 100644
|
|
|
c313de |
--- a/src/util/virjson.h
|
|
|
c313de |
+++ b/src/util/virjson.h
|
|
|
c313de |
@@ -26,6 +26,7 @@
|
|
|
c313de |
|
|
|
c313de |
# include "internal.h"
|
|
|
c313de |
# include "virbitmap.h"
|
|
|
c313de |
+# include "viralloc.h"
|
|
|
c313de |
|
|
|
c313de |
# include <stdarg.h>
|
|
|
c313de |
|
|
|
c313de |
@@ -156,4 +157,6 @@ char *virJSONStringReformat(const char *jsonstr, bool pretty);
|
|
|
c313de |
|
|
|
c313de |
virJSONValuePtr virJSONValueObjectDeflatten(virJSONValuePtr json);
|
|
|
c313de |
|
|
|
c313de |
+VIR_DEFINE_AUTOPTR_FUNC(virJSONValue, virJSONValueFree)
|
|
|
c313de |
+
|
|
|
c313de |
#endif /* __VIR_JSON_H_ */
|
|
|
c313de |
--
|
|
|
c313de |
2.22.0
|
|
|
c313de |
|