Skip to content

Commit

Permalink
fi_list: Added slist_find_first_match() that returns the first match …
Browse files Browse the repository at this point in the history
…from a slist

Signed-off-by: Shantonu Hossain <[email protected]>
  • Loading branch information
shantonu committed Jun 30, 2016
1 parent 3b4fb2b commit 9d15640
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion include/fi_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ static inline struct slist_entry *slist_remove_head(struct slist *list)

typedef int slist_func_t(struct slist_entry *item, const void *arg);

static inline struct slist_entry *
slist_find_first_match(const struct slist *list, slist_func_t *match,
const void *arg)
{
struct slist_entry *item;
for (item = list->head; item; item = item->next) {
if (match(item, arg))
return item;
}

return NULL;
}

static inline struct slist_entry *
slist_remove_first_match(struct slist *list, slist_func_t *match, const void *arg)
{
Expand Down Expand Up @@ -270,7 +283,7 @@ static inline int dlistfd_wait_avail(struct dlistfd_head *head, int timeout)

if (!dlistfd_empty(head))
return 1;

ret = fd_signal_poll(&head->signal, timeout);
return ret ? ret : !dlistfd_empty(head);
}
Expand Down

0 comments on commit 9d15640

Please sign in to comment.