---
docs/apibuild.py | 1 +
src/libvirt_private.syms | 1 +
src/util/virtypedparam.c | 34 ++++++++++++++++++++++++++++++++++
src/util/virtypedparam.h | 4 ++++
4 files changed, 40 insertions(+)
diff --git a/docs/apibuild.py b/docs/apibuild.py
index e0996bf..aca2370 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -69,6 +69,7 @@ ignored_functions = {
"virTypedParameterAssignFromStr": "internal function in
virtypedparam.c",
"virTypedParameterToString": "internal function in
virtypedparam.c",
"virTypedParamsCheck": "internal function in virtypedparam.c",
+ "virTypedParamsCopy": "internal function in virtypedparam.c",
}
ignored_macros = {
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0e0c3bc..fa1041c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1903,6 +1903,7 @@ virTypedParameterToString;
virTypedParameterTypeFromString;
virTypedParameterTypeToString;
virTypedParamsCheck;
+virTypedParamsCopy;
virTypedParamsReplaceString;
virTypedParamsValidate;
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
index 8b18a5a..cf0fde5 100644
--- a/src/util/virtypedparam.c
+++ b/src/util/virtypedparam.c
@@ -382,6 +382,40 @@ error:
}
+int
+virTypedParamsCopy(virTypedParameterPtr *dst,
+ virTypedParameterPtr src,
+ int nparams)
+{
+ int i;
+
+ *dst = NULL;
+ if (!src || nparams <= 0)
+ return 0;
+
+ if (VIR_ALLOC_N(*dst, nparams) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ for (i = 0; i < nparams; i++) {
+ ignore_value(virStrcpyStatic((*dst)[i].field, src[i].field));
+ (*dst)[i].type = src[i].type;
+ if (src[i].type == VIR_TYPED_PARAM_STRING) {
+ if (VIR_STRDUP((*dst)[i].value.s, src[i].value.s) < 0) {
+ virTypedParamsFree(*dst, i - 1);
+ *dst = NULL;
+ return -1;
+ }
+ } else {
+ (*dst)[i].value = src[i].value;
+ }
+ }
+
+ return 0;
+}
+
+
/* The following APIs are public and their signature may never change. */
/**
diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h
index ca062c0..728cae3 100644
--- a/src/util/virtypedparam.h
+++ b/src/util/virtypedparam.h
@@ -50,6 +50,10 @@ int virTypedParamsReplaceString(virTypedParameterPtr *params,
const char *name,
const char *value);
+int virTypedParamsCopy(virTypedParameterPtr *dst,
+ virTypedParameterPtr src,
+ int nparams);
+
char *virTypedParameterToString(virTypedParameterPtr param);
VIR_ENUM_DECL(virTypedParameter)
--
1.8.2.1