[PATCH v3 10/25] util: virtypedparam: Introduce 'virTypedParamListFetch'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce a helper that fetches the typed parameters from the list while
still preserving ownership of the pointer by the list.

In the future this will be also able to report errors stored in the
list.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx
---
 src/libvirt_private.syms |  1 +
 src/util/virtypedparam.c | 26 ++++++++++++++++++++++++++
 src/util/virtypedparam.h |  6 ++++++
 3 files changed, 33 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0f42c2de0b..f1999d0e99 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3556,6 +3556,7 @@ virTypedParamListAddString;
 virTypedParamListAddUInt;
 virTypedParamListAddULLong;
 virTypedParamListConcat;
+virTypedParamListFetch;
 virTypedParamListFree;
 virTypedParamListFromParams;
 virTypedParamListNew;
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
index f8dce9ed98..6e837c65bc 100644
--- a/src/util/virtypedparam.c
+++ b/src/util/virtypedparam.c
@@ -747,6 +747,32 @@ virTypedParamListFree(virTypedParamList *list)
 }


+/**
+ * virTypedParamListFetch:
+ *
+ * @list: virTypedParamList object
+ * @par: if not NULL filled with the typed parameters stored in @list
+ * @npar: if not NULL filled with the number of typed parameters stored in @list
+ *
+ * Checks that @list has no errors stored and optionally fills @par and @npar
+ * with a valid list of typed parametes. The typed parameters still belong to
+ * @list and will be freed together.
+ */
+int
+virTypedParamListFetch(virTypedParamList *list,
+                       virTypedParameterPtr *par,
+                       size_t *npar)
+{
+    if (par)
+        *par = list->par;
+
+    if (npar)
+        *npar = list->npar;
+
+    return 0;
+}
+
+
 size_t
 virTypedParamListStealParams(virTypedParamList *list,
                              virTypedParameterPtr *params)
diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h
index 45422c2673..628c951432 100644
--- a/src/util/virtypedparam.h
+++ b/src/util/virtypedparam.h
@@ -152,6 +152,12 @@ size_t
 virTypedParamListStealParams(virTypedParamList *list,
                              virTypedParameterPtr *params);

+int
+virTypedParamListFetch(virTypedParamList *list,
+                           virTypedParameterPtr *par,
+                           size_t *npar)
+    G_GNUC_WARN_UNUSED_RESULT;
+
 virTypedParamList *
 virTypedParamListFromParams(virTypedParameterPtr *params,
                             size_t nparams);
-- 
2.39.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux