summaryrefslogtreecommitdiff
path: root/lib/linklist.h
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2018-12-07 22:06:42 +0000
committerQuentin Young <qlyoung@cumulusnetworks.com>2019-05-17 00:27:08 +0000
commit4440e3cdf7860a036836216ffa80a6ef82096901 (patch)
tree21c4a47c20c677c2756348664b0e3efef711c7e3 /lib/linklist.h
parent69f63d1af96b14027152700fafed55c0e5f80562 (diff)
lib: add list_to_array
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/linklist.h')
-rw-r--r--lib/linklist.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/linklist.h b/lib/linklist.h
index c30d8d314a..c2b289596d 100644
--- a/lib/linklist.h
+++ b/lib/linklist.h
@@ -240,6 +240,26 @@ extern void list_sort(struct list *list,
int (*cmp)(const void **, const void **));
/*
+ * Convert a list to an array of void pointers.
+ *
+ * Starts from the list head and ends either on the last node of the list or
+ * when the provided array cannot store any more elements.
+ *
+ * list
+ * list to convert
+ *
+ * arr
+ * Pre-allocated array of void *
+ *
+ * arrlen
+ * Number of elements in arr
+ *
+ * Returns:
+ * arr
+ */
+void **list_to_array(struct list *list, void **arr, size_t arrlen);
+
+/*
* Delete a list and NULL its pointer.
*
* If non-null, list->del is called with each data element.