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>
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);
}