Function llist_copy2

Function Documentation

struct llist *llist_copy2(struct llist *list, bool_t (*pred)(const void *e), uint32_t flags, void *elements, void *nodes)

Create a copy of part of a llist (conditional copy).

This routine iterates through the list and finds all the items that satisfy the predicate, and duplicates them, creating a new list contain all the nodes in the orginal list that satisfied the predicate. If no elements are found that fulfill the predicate, an empty list is returned.

Parameters:
  • list – The linked list handle.

  • pred – The predicate for determining element membership in the new list

  • flags – Initialization flags for the new list.

  • elements – Space for elements in the new list. Must be non-NULL if RCSW_NOALLOC_DATA is passed in flags; can be NULL otherwise.

  • nodes – Space for nodes in the new list. Must be non-NULL if RCSW_NOALLOC_META is passed in flags; can be NULL otherwise.

Returns:

The new list, or NULL if an error occurred.