diff options
Diffstat (limited to 'string-list.h')
-rw-r--r-- | string-list.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/string-list.h b/string-list.h index de6769c92d..d3809a1417 100644 --- a/string-list.h +++ b/string-list.h @@ -15,8 +15,10 @@ struct string_list { compare_strings_fn cmp; /* NULL uses strcmp() */ }; -#define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0 } -#define STRING_LIST_INIT_DUP { NULL, 0, 0, 1 } +#define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0, NULL } +#define STRING_LIST_INIT_DUP { NULL, 0, 0, 1, NULL } + +void string_list_init(struct string_list *list, int strdup_strings); void print_string_list(const struct string_list *p, const char *text); void string_list_clear(struct string_list *list, int free_util); @@ -53,9 +55,17 @@ void string_list_remove_empty_items(struct string_list *list, int free_util); int string_list_has_string(const struct string_list *list, const char *string); int string_list_find_insert_index(const struct string_list *list, const char *string, int negative_existing_index); +/* + * Inserts the given string into the sorted list. + * If the string already exists, the list is not altered. + * Returns the string_list_item, the string is part of. + */ struct string_list_item *string_list_insert(struct string_list *list, const char *string); -struct string_list_item *string_list_insert_at_index(struct string_list *list, - int insert_at, const char *string); + +/* + * Checks if the given string is part of a sorted list. If it is part of the list, + * return the coresponding string_list_item, NULL otherwise. + */ struct string_list_item *string_list_lookup(struct string_list *list, const char *string); /* @@ -83,7 +93,7 @@ struct string_list_item *string_list_append(struct string_list *list, const char */ struct string_list_item *string_list_append_nodup(struct string_list *list, char *string); -void sort_string_list(struct string_list *list); +void string_list_sort(struct string_list *list); int unsorted_string_list_has_string(struct string_list *list, const char *string); struct string_list_item *unsorted_string_list_lookup(struct string_list *list, const char *string); |