]> xenbits.xensource.com Git - libvirt.git/commitdiff
Introduce virTypedParamsCopy internal API
authorJiri Denemark <jdenemar@redhat.com>
Fri, 7 Jun 2013 14:34:13 +0000 (16:34 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 24 Jun 2013 22:38:25 +0000 (00:38 +0200)
docs/apibuild.py
src/libvirt_private.syms
src/util/virtypedparam.c
src/util/virtypedparam.h

index e0996bfcce55d24f53c4eb725e9b46e5a8847656..aca2370110c814d70b26312f4bb56eeadf4022da 100755 (executable)
@@ -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 = {
index 504cec3d71b1fd587cd69e1cdbc2a3e51426a650..92619a06230364ae41a3363e56c369a7874c9b6e 100644 (file)
@@ -1947,6 +1947,7 @@ virTypedParameterToString;
 virTypedParameterTypeFromString;
 virTypedParameterTypeToString;
 virTypedParamsCheck;
+virTypedParamsCopy;
 virTypedParamsReplaceString;
 virTypedParamsValidate;
 
index 88e0951afb2e3d5d03a9971e380908d8d8c7acd0..c767e32a866382f427a1e6b489a012d639baf492 100644 (file)
@@ -395,6 +395,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. */
 
 /**
index 364df2bd10f2484119ad4a4cef44b445aba79004..0c185047b7f13be2fe819caaeb451921ef9ba0c4 100644 (file)
@@ -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)