From da1831de964c02b5b0728bbd2c74dc2c1ff87042 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 19 Aug 2020 13:13:29 +0200 Subject: [PATCH] qemuMigrationParamsNew: Use new memory allocation to simplify code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use automatic memory cleaning and allocate via g_new0. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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) + params = g_new0(qemuMigrationParams, 1); + + if (!(params->caps = virBitmapNew(QEMU_MIGRATION_CAP_LAST))) return NULL; - params->caps = virBitmapNew(QEMU_MIGRATION_CAP_LAST); - if (!params->caps) - goto error; - - return params; - - error: - qemuMigrationParamsFree(params); - return NULL; + return g_steal_pointer(¶ms); }