path: root/string-list.h
diff options
authorMichael Haggerty <>2012-09-12 14:04:44 (GMT)
committerJunio C Hamano <>2012-09-12 18:43:25 (GMT)
commiteb5f0c7a616531a024a582b72ca6d8775ff98d46 (patch)
tree1c791a163140cb2988c7d2049ce706ad93e0c23d /string-list.h
parentff919f965d20d003e3882c70de667f41a86349ac (diff)
string_list: add a new function, filter_string_list()
This function allows entries that don't match a specified criterion to be discarded from a string_list while preserving the order of the remaining entries. Signed-off-by: Michael Haggerty <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'string-list.h')
1 files changed, 9 insertions, 0 deletions
diff --git a/string-list.h b/string-list.h
index dc5fbc8..7d18e62 100644
--- a/string-list.h
+++ b/string-list.h
@@ -29,6 +29,15 @@ int for_each_string_list(struct string_list *list,
#define for_each_string_list_item(item,list) \
for (item = (list)->items; item < (list)->items + (list)->nr; ++item)
+ * Apply want to each item in list, retaining only the ones for which
+ * the function returns true. If free_util is true, call free() on
+ * the util members of any items that have to be deleted. Preserve
+ * the order of the items that are retained.
+ */
+void filter_string_list(struct string_list *list, int free_util,
+ string_list_each_func_t want, void *cb_data);
/* Use these functions only on sorted lists: */
int string_list_has_string(const struct string_list *list, const char *string);