cpu_x86: Use glib allocation in virCPUx86GetModels

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jiri Denemark 2020-03-25 18:41:48 +01:00
parent 247e115e27
commit e43e2ff7f5

View File

@ -3121,21 +3121,13 @@ virCPUx86GetModels(char ***models)
return -1;
if (models) {
if (VIR_ALLOC_N(*models, map->nmodels + 1) < 0)
goto error;
*models = g_new0(char *, map->nmodels + 1);
for (i = 0; i < map->nmodels; i++)
(*models)[i] = g_strdup(map->models[i]->name);
}
return map->nmodels;
error:
if (models) {
virStringListFree(*models);
*models = NULL;
}
return -1;
}