summaryrefslogtreecommitdiff
path: root/string-list.c
diff options
context:
space:
mode:
authorJay Soffian <jaysoffian@gmail.com>2009-02-25 03:32:18 -0500
committerJunio C Hamano <gitster@pobox.com>2009-02-27 15:19:08 -0800
commitc6f5a7a916b36fc9dd00bb6dce3b68260579abe1 (patch)
tree179489dbc983e10eb0c10b259eb699c24a38f4a9 /string-list.c
parent5f48cb95aa0d7311623df76249a1c8a1962550f5 (diff)
downloadgit-c6f5a7a916b36fc9dd00bb6dce3b68260579abe1.tar.gz
string-list: new for_each_string_list() function
Add a convenience function for iterating over a string_list's items via a callback. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'string-list.c')
-rw-r--r--string-list.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/string-list.c b/string-list.c
index 15e14cf47a..1ac536e638 100644
--- a/string-list.c
+++ b/string-list.c
@@ -92,6 +92,16 @@ struct string_list_item *string_list_lookup(const char *string, struct string_li
return list->items + i;
}
+int for_each_string_list(string_list_each_func_t fn,
+ struct string_list *list, void *cb_data)
+{
+ int i, ret = 0;
+ for (i = 0; i < list->nr; i++)
+ if ((ret = fn(&list->items[i], cb_data)))
+ break;
+ return ret;
+}
+
void string_list_clear(struct string_list *list, int free_util)
{
if (list->items) {