[PATCH 1/7] qemuMigrationParamsNew: Use new memory allocation to simplify code

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

 



Use automatic memory cleaning and allocate via g_new0.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_migration_params.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 04434e9557..f466c3c4f6 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -244,20 +244,14 @@ qemuMigrationParamsGetAlwaysOnCaps(qemuMigrationParty party)
 qemuMigrationParamsPtr
 qemuMigrationParamsNew(void)
 {
-    qemuMigrationParamsPtr params;
+    g_autoptr(qemuMigrationParams) params = NULL;

-    if (VIR_ALLOC(params) < 0)
-        return NULL;
-
-    params->caps = virBitmapNew(QEMU_MIGRATION_CAP_LAST);
-    if (!params->caps)
-        goto error;
+    params = g_new0(qemuMigrationParams, 1);

-    return params;
+    if (!(params->caps = virBitmapNew(QEMU_MIGRATION_CAP_LAST)))
+        return NULL;

- error:
-    qemuMigrationParamsFree(params);
-    return NULL;
+    return g_steal_pointer(&params);
 }


-- 
2.26.2




[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