mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
Introduce virTypedParamsCopy internal API
This commit is contained in:
parent
173a14ec0b
commit
d0d5acb511
@ -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 = {
|
||||
|
@ -1947,6 +1947,7 @@ virTypedParameterToString;
|
||||
virTypedParameterTypeFromString;
|
||||
virTypedParameterTypeToString;
|
||||
virTypedParamsCheck;
|
||||
virTypedParamsCopy;
|
||||
virTypedParamsReplaceString;
|
||||
virTypedParamsValidate;
|
||||
|
||||
|
@ -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. */
|
||||
|
||||
/**
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user