diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-10-04 09:34:06 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-10-05 12:25:48 +0200 |
commit | 1fa9564916ea9cd92622b5a549693d23fbf35bcb (patch) | |
tree | 15994eb6cbbbfc0e59c14a3de0e1635240a5c494 /src/llist.c | |
parent | a0afb7ded2fba68e710afda1053dba2a20b4665f (diff) | |
download | calcurse-1fa9564916ea9cd92622b5a549693d23fbf35bcb.zip |
src/llist.c: Add llist_next_filter()
This convenience function can be used to return the successor of a list
item if it is matched by a filter callback and return NULL otherwise.
We will use this for an improved version of the LLIST_FIND_FOREACH macro
that can be used whenever results are known to be continuous.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/llist.c')
-rw-r--r-- | src/llist.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/llist.c b/src/llist.c index 7611595..a85cfa9 100644 --- a/src/llist.c +++ b/src/llist.c @@ -115,6 +115,19 @@ llist_next (llist_item_t *i) } /* + * Return the successor of a list item if it is matched by some filter + * callback. Return NULL otherwise. + */ +llist_item_t * +llist_next_filter (llist_item_t *i, long data, llist_fn_match_t fn_match) +{ + if (i && i->next && fn_match (i->next->data, data)) + return i->next; + else + return NULL; +} + +/* * Get the actual data of an item. */ void * |