qemuMigrationParamsNew: Use new memory allocation to simplify code

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>
This commit is contained in:
Peter Krempa 2020-08-19 13:13:29 +02:00
parent 9586367d7e
commit da1831de96

View File

@ -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(&params);
}