[PATCH 02/21] qemu: qapi: Use automatic memory cleanup

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

 



Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_qapi.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c
index 427809e9e3..90df50ec77 100644
--- a/src/qemu/qemu_qapi.c
+++ b/src/qemu/qemu_qapi.c
@@ -207,7 +207,7 @@ virQEMUQAPISchemaPathGet(const char *query,
                          virHashTablePtr schema,
                          virJSONValuePtr *entry)
 {
-    char **elems = NULL;
+    VIR_AUTOSTRINGLIST elems = NULL;

     *entry = NULL;

@@ -216,13 +216,11 @@ virQEMUQAPISchemaPathGet(const char *query,

     if (!*elems) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed query string"));
-        virStringListFree(elems);
         return -1;
     }

     *entry = virQEMUQAPISchemaTraverse(*elems, elems + 1, schema);

-    virStringListFree(elems);
     return 0;
 }

@@ -270,21 +268,16 @@ virQEMUQAPISchemaEntryProcess(size_t pos ATTRIBUTE_UNUSED,
 virHashTablePtr
 virQEMUQAPISchemaConvert(virJSONValuePtr schemareply)
 {
-    virHashTablePtr schema;
-    virHashTablePtr ret = NULL;
+    VIR_AUTOPTR(virHashTable) schema = NULL;
+    VIR_AUTOPTR(virJSONValue) schemajson = schemareply;

     if (!(schema = virHashCreate(512, virJSONValueHashFree)))
-        goto cleanup;
+        return NULL;

-    if (virJSONValueArrayForeachSteal(schemareply,
+    if (virJSONValueArrayForeachSteal(schemajson,
                                       virQEMUQAPISchemaEntryProcess,
                                       schema) < 0)
-        goto cleanup;
-
-    VIR_STEAL_PTR(ret, schema);
+        return NULL;

- cleanup:
-    virJSONValueFree(schemareply);
-    virHashFree(schema);
-    return ret;
+    VIR_RETURN_PTR(schema);
 }
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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