]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: typedparam: Introduce 'virTypedParamListConcat'
authorPeter Krempa <pkrempa@redhat.com>
Tue, 18 Apr 2023 13:30:16 +0000 (15:30 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 May 2023 12:32:46 +0000 (14:32 +0200)
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>
src/libvirt_private.syms
src/util/virtypedparam.c
src/util/virtypedparam.h

index c596ef0f87282166b39b77f02163434a6c4b6a3c..0f42c2de0b9e9014599e17de75f5d86ee7fbe711 100644 (file)
@@ -3555,6 +3555,7 @@ virTypedParamListAddLLong;
 virTypedParamListAddString;
 virTypedParamListAddUInt;
 virTypedParamListAddULLong;
+virTypedParamListConcat;
 virTypedParamListFree;
 virTypedParamListFromParams;
 virTypedParamListNew;
index de3a4e76b4f56ae9472f2e4ced5de40bec03b3d8..6ac9a4e2f3c268e6cebdda98f8b139d44bbe25d6 100644 (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)
 {
index 4aa597bc811e7a00f13480e71982030433af7ce2..45422c2673c5f561c731c3f89db0bb6cef33e5c7 100644 (file)
@@ -156,6 +156,10 @@ virTypedParamList *
 virTypedParamListFromParams(virTypedParameterPtr *params,
                             size_t nparams);
 
+void
+virTypedParamListConcat(virTypedParamList *to,
+                        virTypedParamList **fromptr);
+
 int
 virTypedParamListAddInt(virTypedParamList *list,
                         int value,