From: Peter Krempa Date: Wed, 19 Aug 2020 11:13:29 +0000 (+0200) Subject: qemuMigrationParamsNew: Use new memory allocation to simplify code X-Git-Tag: v6.7.0-rc1~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da1831de964c02b5b0728bbd2c74dc2c1ff87042;p=thirdparty%2Flibvirt.git qemuMigrationParamsNew: Use new memory allocation to simplify code Use automatic memory cleaning and allocate via g_new0. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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(¶ms); }