util: typedparam: Introduce 'virTypedParamListConcat'

Introduce a helper function to concatenate two virTypedParamLists. This
will allow us to refactor qemuDomainGetStatsBlock to not access the list
directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Peter Krempa 2023-04-18 15:30:16 +02:00
parent 0d09e79b42
commit e3dff704bf
3 changed files with 28 additions and 0 deletions

View File

@ -3555,6 +3555,7 @@ virTypedParamListAddLLong;
virTypedParamListAddString;
virTypedParamListAddUInt;
virTypedParamListAddULLong;
virTypedParamListConcat;
virTypedParamListFree;
virTypedParamListFromParams;
virTypedParamListNew;

View File

@ -712,6 +712,29 @@ virTypedParamListNew(void)
}
/**
* virTypedParamListConcat:
* @to: typed param list to concatenate into
* @fromptr: pointer to pointer to a typed param list to concatenate into @to
*
* Concatenates all params from the virTypedParamList pointed to by @fromptr
* into @to and deallocates the list pointed to by @fromptr and clears the
* variable.
*/
void
virTypedParamListConcat(virTypedParamList *to,
virTypedParamList **fromptr)
{
g_autoptr(virTypedParamList) from = g_steal_pointer(fromptr);
VIR_RESIZE_N(to->par, to->par_alloc, to->npar, from->npar);
memcpy(to->par + to->npar, from->par, sizeof(*(to->par)) * from->npar);
to->npar += from->npar;
from->npar = 0;
}
void
virTypedParamListFree(virTypedParamList *list)
{

View File

@ -156,6 +156,10 @@ virTypedParamList *
virTypedParamListFromParams(virTypedParameterPtr *params,
size_t nparams);
void
virTypedParamListConcat(virTypedParamList *to,
virTypedParamList **fromptr);
int
virTypedParamListAddInt(virTypedParamList *list,
int value,