diff options
Diffstat (limited to 'string-list.h')
-rw-r--r-- | string-list.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/string-list.h b/string-list.h index 5efd07b44e..de6769c92d 100644 --- a/string-list.h +++ b/string-list.h @@ -5,10 +5,14 @@ struct string_list_item { char *string; void *util; }; + +typedef int (*compare_strings_fn)(const char *, const char *); + struct string_list { struct string_list_item *items; unsigned int nr, alloc; unsigned int strdup_strings:1; + compare_strings_fn cmp; /* NULL uses strcmp() */ }; #define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0 } @@ -39,13 +43,11 @@ void filter_string_list(struct string_list *list, int free_util, string_list_each_func_t want, void *cb_data); /* - * Return the longest string in prefixes that is a prefix (in the - * sense of prefixcmp()) of string, or NULL if no such prefix exists. - * This function does not require the string_list to be sorted (it - * does a linear search). + * 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. */ -char *string_list_longest_prefix(const struct string_list *prefixes, const char *string); - +void string_list_remove_empty_items(struct string_list *list, int free_util); /* Use these functions only on sorted lists: */ int string_list_has_string(const struct string_list *list, const char *string); |