mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 23:25:24 +00:00
cpu_x86: Use glib allocation for virCPUx86Model
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
51b6e9c100
commit
ccc0c2e4de
@ -1111,29 +1111,18 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static virCPUx86ModelPtr
|
|
||||||
x86ModelNew(void)
|
|
||||||
{
|
|
||||||
virCPUx86ModelPtr model;
|
|
||||||
|
|
||||||
if (VIR_ALLOC(model) < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
x86ModelFree(virCPUx86ModelPtr model)
|
x86ModelFree(virCPUx86ModelPtr model)
|
||||||
{
|
{
|
||||||
if (!model)
|
if (!model)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
VIR_FREE(model->name);
|
g_free(model->name);
|
||||||
VIR_FREE(model->signatures);
|
g_free(model->signatures);
|
||||||
virCPUx86DataClear(&model->data);
|
virCPUx86DataClear(&model->data);
|
||||||
VIR_FREE(model);
|
g_free(model);
|
||||||
}
|
}
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCPUx86Model, x86ModelFree);
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1161,9 +1150,7 @@ x86ModelCopy(virCPUx86ModelPtr model)
|
|||||||
{
|
{
|
||||||
virCPUx86ModelPtr copy;
|
virCPUx86ModelPtr copy;
|
||||||
|
|
||||||
if (VIR_ALLOC(copy) < 0)
|
copy = g_new0(virCPUx86Model, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
copy->name = g_strdup(model->name);
|
copy->name = g_strdup(model->name);
|
||||||
|
|
||||||
if (x86ModelCopySignatures(copy, model) < 0) {
|
if (x86ModelCopySignatures(copy, model) < 0) {
|
||||||
@ -1216,7 +1203,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
|
|||||||
if (cpu->type == VIR_CPU_TYPE_HOST &&
|
if (cpu->type == VIR_CPU_TYPE_HOST &&
|
||||||
policy != VIR_CPU_FEATURE_REQUIRE &&
|
policy != VIR_CPU_FEATURE_REQUIRE &&
|
||||||
policy != -1)
|
policy != -1)
|
||||||
return x86ModelNew();
|
return g_new0(virCPUx86Model, 1);
|
||||||
|
|
||||||
if (cpu->model &&
|
if (cpu->model &&
|
||||||
(policy == VIR_CPU_FEATURE_REQUIRE || policy == -1)) {
|
(policy == VIR_CPU_FEATURE_REQUIRE || policy == -1)) {
|
||||||
@ -1228,7 +1215,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
|
|||||||
|
|
||||||
model = x86ModelCopy(model);
|
model = x86ModelCopy(model);
|
||||||
} else {
|
} else {
|
||||||
model = x86ModelNew();
|
model = g_new0(virCPUx86Model, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!model)
|
if (!model)
|
||||||
@ -1540,9 +1527,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(model = x86ModelNew()))
|
model = g_new0(virCPUx86Model, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
model->name = g_strdup(name);
|
model->name = g_strdup(name);
|
||||||
|
|
||||||
if (x86ModelParseDecode(model, ctxt) < 0)
|
if (x86ModelParseDecode(model, ctxt) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user