summaryrefslogtreecommitdiff
path: root/string-list.c
diff options
context:
space:
mode:
Diffstat (limited to 'string-list.c')
-rw-r--r--string-list.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/string-list.c b/string-list.c
index c54b816244..480173fe6d 100644
--- a/string-list.c
+++ b/string-list.c
@@ -136,24 +136,13 @@ void filter_string_list(struct string_list *list, int free_util,
list->nr = dst;
}
-char *string_list_longest_prefix(const struct string_list *prefixes,
- const char *string)
+static int item_is_not_empty(struct string_list_item *item, void *unused)
{
- int i, max_len = -1;
- char *retval = NULL;
-
- for (i = 0; i < prefixes->nr; i++) {
- char *prefix = prefixes->items[i].string;
- if (!prefixcmp(string, prefix)) {
- int len = strlen(prefix);
- if (len > max_len) {
- retval = prefix;
- max_len = len;
- }
- }
- }
+ return *item->string != '\0';
+}
- return retval;
+void string_list_remove_empty_items(struct string_list *list, int free_util) {
+ filter_string_list(list, free_util, item_is_not_empty, NULL);
}
void string_list_clear(struct string_list *list, int free_util)