]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMigrationParamsNew: Use new memory allocation to simplify code
authorPeter Krempa <pkrempa@redhat.com>
Wed, 19 Aug 2020 11:13:29 +0000 (13:13 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 24 Aug 2020 14:34:50 +0000 (16:34 +0200)
Use automatic memory cleaning and allocate via g_new0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_migration_params.c

index 04434e9557c79c32a82761f7a90e392f886f42d0..f466c3c4f6d2330ac877ae4301323a8949465cbe 100644 (file)
@@ -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);
 }