summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2010-07-03 12:40:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-07-05 18:44:24 (GMT)
commit8d31635ce22a5ff35d6b023dca6438c09cf49dc9 (patch)
tree5fa9620895f1739b701abaf7e959e9bf73a30a42
parent45e9a825edf9064ff76f6ff10357fdc79497f0eb (diff)
downloadgit-8d31635ce22a5ff35d6b023dca6438c09cf49dc9.zip
git-8d31635ce22a5ff35d6b023dca6438c09cf49dc9.tar.gz
git-8d31635ce22a5ff35d6b023dca6438c09cf49dc9.tar.bz2
Add a for_each_string_list_item macro
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>
-rw-r--r--string-list.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/string-list.h b/string-list.h
index 680d600..a37cae5 100644
--- a/string-list.h
+++ b/string-list.h
@@ -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);