Skip to content

Commit

Permalink
Add a for_each_string_list_item macro
Browse files Browse the repository at this point in the history
This is more lightweight than a call to for_each_string_list function with
callback function and a cookie argument.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Alex Riesen authored and Junio C Hamano committed Jul 5, 2010
1 parent 45e9a82 commit 8d31635
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion string-list.h
Original file line number Diff line number Diff line change
@@ -20,10 +20,12 @@ void string_list_clear(struct string_list *list, int free_util);
typedef void (*string_list_clear_func_t)(void *p, const char *str);
void string_list_clear_func(struct string_list *list, string_list_clear_func_t clearfunc);

/* Use this function to iterate over each item */
/* Use this function or the macro below to iterate over each item */
typedef int (*string_list_each_func_t)(struct string_list_item *, void *);
int for_each_string_list(struct string_list *list,
string_list_each_func_t, void *cb_data);
#define for_each_string_list_item(item,list) \
for (item = (list)->items; item < (list)->items + (list)->nr; ++item)

/* Use these functions only on sorted lists: */
int string_list_has_string(const struct string_list *list, const char *string);

0 comments on commit 8d31635

Please sign in to comment.