string_list: add a function string_list_remove_empty_items()

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Acked-by: Johan Herland <johan@herland.net>
Signed-off-by: Jeff King <peff@peff.net>
This commit is contained in:
Michael Haggerty
2012-11-04 08:07:06 +01:00
committed by Jeff King
parent 9c50374497
commit 6bb2a1377b
3 changed files with 24 additions and 1 deletions

View File

@ -38,6 +38,13 @@ int for_each_string_list(struct string_list *list,
void filter_string_list(struct string_list *list, int free_util,
string_list_each_func_t want, void *cb_data);
/*
* Remove any empty strings from the list. 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 string_list_remove_empty_items(struct string_list *list, int free_util);
/*
* Return the longest string in prefixes that is a prefix (in the
* sense of prefixcmp()) of string, or NULL if no such prefix exists.