Function llist_filter

Function Documentation

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

Filter out elements from one llist into another.

This routine iterates through the llist and finds all the items that satisfy the predicate, and moves them into a new list (they are removed from the original list). If no elements are found that fulfill the predicate, an empty list is returned.

Parameters:
  • list – The linked list handle

  • 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.

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

Returns:

The new list, or NULL if an error occurred.