Both virDomainCapsCPUModelsAdd and virDomainCapsCPUModelsAddSteal are so
simple we can just squash the code in a single function.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Notes:
Version 2:
- no change
src/conf/domain_capabilities.c | 33 ++++++++++-----------------------
src/conf/domain_capabilities.h | 4 ----
src/libvirt_private.syms | 1 -
3 files changed, 10 insertions(+), 28 deletions(-)
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index a13463a6e7..dadb2a1183 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -185,27 +185,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;
- VIR_STEAL_PTR(cpuModels->models[cpuModels->nmodels].name, *name);
-
- if (blockers)
- VIR_STEAL_PTR(cpuModels->models[cpuModels->nmodels].blockers, *blockers);
-
- cpuModels->nmodels++;
- return 0;
-}
-
-
int
virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
const char *name,
@@ -214,6 +193,7 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
{
VIR_AUTOFREE(char *) nameCopy = NULL;
VIR_AUTOSTRINGLIST blockersCopy = NULL;
+ virDomainCapsCPUModelPtr cpu;
if (VIR_STRDUP(nameCopy, name) < 0)
return -1;
@@ -221,10 +201,17 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
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;
+ VIR_STEAL_PTR(cpu->name, nameCopy);
+ VIR_STEAL_PTR(cpu->blockers, blockersCopy);
+
return 0;
}
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index bdd0bd9253..8b220e3bf8 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -195,10 +195,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,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 641b1f93bd..b35934be1f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -191,7 +191,6 @@ virDomainAuditVcpu;
# conf/domain_capabilities.h
virDomainCapsCPUModelsAdd;
-virDomainCapsCPUModelsAddSteal;
virDomainCapsCPUModelsCopy;
virDomainCapsCPUModelsGet;
virDomainCapsCPUModelsNew;
--
2.23.0