Function returns number of virCPUDefPtrs in list --- src/conf/cpu_conf.c | 15 +++++++++++++++ src/conf/cpu_conf.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 19 insertions(+) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 43a3ab5dcd..ff978ec083 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -1039,3 +1039,18 @@ virCPUDefListFree(virCPUDefPtr *cpus) VIR_FREE(cpus); } + + +/* + * Return number of virCPUDefPtrs in list + */ +size_t +virCPUDefListLength(virCPUDefPtr *cpus) +{ + size_t i = 0; + + while (cpus && cpus[i]) + i++; + + return i; +} diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index 9f2e7ee264..a0743e5d9b 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -227,4 +227,7 @@ virCPUDefListParse(const char **xmlCPUs, void virCPUDefListFree(virCPUDefPtr *cpus); +size_t +virCPUDefListLength(virCPUDefPtr *cpus); + #endif /* __VIR_CPU_CONF_H__ */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 98913a577a..66e74e3fb7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -85,6 +85,7 @@ virCPUDefFreeFeatures; virCPUDefFreeModel; virCPUDefIsEqual; virCPUDefListFree; +virCPUDefListLength; virCPUDefListParse; virCPUDefParseXML; virCPUDefStealModel; -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list