Introduce virTypedParamsCopy internal API

This commit is contained in:
Jiri Denemark 2013-06-07 16:34:13 +02:00
parent 173a14ec0b
commit d0d5acb511
4 changed files with 40 additions and 0 deletions

View File

@ -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 = {

View File

@ -1947,6 +1947,7 @@ virTypedParameterToString;
virTypedParameterTypeFromString;
virTypedParameterTypeToString;
virTypedParamsCheck;
virTypedParamsCopy;
virTypedParamsReplaceString;
virTypedParamsValidate;

View 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. */
/**

View 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)