mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
conf: Drop virDomainCapsCPUModelsAddSteal
Both virDomainCapsCPUModelsAdd and virDomainCapsCPUModelsAddSteal are so simple we can just squash the code in a single function. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
180ac4ca34
commit
1f58d10197
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user