[PATCH 02/18] virJSONValueObjectAddVArgs: Take double pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pass in the double pointer from the wrappers directly to
virJSONValueObjectAddVArgs, which will allow us to directly allocate the
new objects inside the function.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_monitor.c | 2 +-
 src/util/virjson.c      | 9 +++++----
 src/util/virjson.h      | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 810dac209d..398bef2e96 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2889,7 +2889,7 @@ qemuMonitorCreateObjectProps(virJSONValue **propsret,

     va_start(args, alias);

-    rc = virJSONValueObjectAddVArgs(props, args);
+    rc = virJSONValueObjectAddVArgs(&props, args);

     va_end(args);

diff --git a/src/util/virjson.c b/src/util/virjson.c
index 446b675309..bd71b84960 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -103,7 +103,7 @@ virJSONValueGetType(const virJSONValue *value)

 /**
  * virJSONValueObjectAddVArgs:
- * @obj: JSON object to add the values to
+ * @objptr: pointer to a pointer to a JSON object to add the values to
  * @args: a key-value argument pairs, terminated by NULL
  *
  * Adds the key-value pairs supplied as variable argument list to @obj.
@@ -152,9 +152,10 @@ virJSONValueGetType(const virJSONValue *value)
  * in case of no error but nothing was filled.
  */
 int
-virJSONValueObjectAddVArgs(virJSONValue *obj,
+virJSONValueObjectAddVArgs(virJSONValue **objptr,
                            va_list args)
 {
+    virJSONValue *obj = *objptr;
     char type;
     char *key;
     int rc;
@@ -354,7 +355,7 @@ virJSONValueObjectAdd(virJSONValue **objptr, ...)
     int ret;

     va_start(args, objptr);
-    ret = virJSONValueObjectAddVArgs(*objptr, args);
+    ret = virJSONValueObjectAddVArgs(objptr, args);
     va_end(args);

     return ret;
@@ -370,7 +371,7 @@ virJSONValueObjectCreateVArgs(virJSONValue **obj,
     *obj = virJSONValueNewObject();

     /* free the object on error, or if no value objects were added */
-    if ((ret = virJSONValueObjectAddVArgs(*obj, args)) <= 0) {
+    if ((ret = virJSONValueObjectAddVArgs(obj, args)) <= 0) {
         virJSONValueFree(*obj);
         *obj = NULL;
     }
diff --git a/src/util/virjson.h b/src/util/virjson.h
index c5d969f0fc..0d8dad754d 100644
--- a/src/util/virjson.h
+++ b/src/util/virjson.h
@@ -50,7 +50,7 @@ int virJSONValueObjectCreateVArgs(virJSONValue **obj, va_list args)
     ATTRIBUTE_NONNULL(1);
 int virJSONValueObjectAdd(virJSONValue **obj, ...)
     ATTRIBUTE_NONNULL(1) G_GNUC_NULL_TERMINATED;
-int virJSONValueObjectAddVArgs(virJSONValue *obj, va_list args)
+int virJSONValueObjectAddVArgs(virJSONValue **objptr, va_list args)
     ATTRIBUTE_NONNULL(1);


-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux