提交 1f58d101 编写于 作者: J Jiri Denemark

conf: Drop virDomainCapsCPUModelsAddSteal

Both virDomainCapsCPUModelsAdd and virDomainCapsCPUModelsAddSteal are so
simple we can just squash the code in a single function.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 180ac4ca
......@@ -190,27 +190,6 @@ virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old)
}
int
virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels,
char **name,
virDomainCapsCPUUsable usable,
char ***blockers)
{
if (VIR_RESIZE_N(cpuModels->models, cpuModels->nmodels_max,
cpuModels->nmodels, 1) < 0)
return -1;
cpuModels->models[cpuModels->nmodels].usable = usable;
cpuModels->models[cpuModels->nmodels].name = g_steal_pointer(&*name);
if (blockers)
cpuModels->models[cpuModels->nmodels].blockers = g_steal_pointer(&*blockers);
cpuModels->nmodels++;
return 0;
}
int
virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
const char *name,
......@@ -219,16 +198,24 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
{
g_autofree char * nameCopy = NULL;
VIR_AUTOSTRINGLIST blockersCopy = NULL;
virDomainCapsCPUModelPtr cpu;
nameCopy = g_strdup(name);
if (virStringListCopy(&blockersCopy, (const char **)blockers) < 0)
return -1;
if (virDomainCapsCPUModelsAddSteal(cpuModels, &nameCopy,
usable, &blockersCopy) < 0)
if (VIR_RESIZE_N(cpuModels->models, cpuModels->nmodels_max,
cpuModels->nmodels, 1) < 0)
return -1;
cpu = cpuModels->models + cpuModels->nmodels;
cpuModels->nmodels++;
cpu->usable = usable;
cpu->name = g_steal_pointer(&nameCopy);
cpu->blockers = g_steal_pointer(&blockersCopy);
return 0;
}
......
......@@ -203,10 +203,6 @@ virDomainCapsPtr virDomainCapsNew(const char *path,
virDomainCapsCPUModelsPtr virDomainCapsCPUModelsNew(size_t nmodels);
virDomainCapsCPUModelsPtr virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old);
int virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels,
char **name,
virDomainCapsCPUUsable usable,
char ***blockers);
int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
const char *name,
virDomainCapsCPUUsable usable,
......
......@@ -192,7 +192,6 @@ virDomainAuditVcpu;
# conf/domain_capabilities.h
virDomainCapsCPUModelsAdd;
virDomainCapsCPUModelsAddSteal;
virDomainCapsCPUModelsCopy;
virDomainCapsCPUModelsGet;
virDomainCapsCPUModelsNew;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册