summaryrefslogtreecommitdiff
path: root/string-list.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-10-14 12:56:08 -0700
committerJunio C Hamano <gitster@pobox.com>2025-10-14 12:56:08 -0700
commit048625a6898f2bcc212f0d4baec1d18695b028a5 (patch)
tree8a7ea947d64d5bd9a7fe79770b5056e8485cb14c /string-list.h
parentca5a44b15c0b47e4e2588541e735dfac7ebd888c (diff)
parent22e7bc801cd9c5e5b5c4489b631be28e506fec42 (diff)
Merge branch 'sj/string-list'
The "string-list" API function to find where a given string would be inserted got updated so that it can use unrealistically huge array index that would only fit in size_t but not int or ssize_t to achieve unstated goal. * sj/string-list: refs: enable sign compare warnings check string-list: change "string_list_find_insert_index" return type to "size_t" string-list: replace negative index encoding with "exact_match" parameter string-list: use bool instead of int for "exact_match"
Diffstat (limited to 'string-list.h')
-rw-r--r--string-list.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/string-list.h b/string-list.h
index 2b438c7733..fa6ba07853 100644
--- a/string-list.h
+++ b/string-list.h
@@ -172,9 +172,15 @@ void string_list_remove_empty_items(struct string_list *list, int free_util);
/* Use these functions only on sorted lists: */
/** Determine if the string_list has a given string or not. */
-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);
+bool string_list_has_string(const struct string_list *list, const char *string);
+
+/**
+ * Find the index at which a new element should be inserted into the
+ * string_list to maintain sorted order. If exact_match is not NULL,
+ * it will be set to true if the string already exists in the list.
+ */
+size_t string_list_find_insert_index(const struct string_list *list, const char *string,
+ bool *exact_match);
/**
* Insert a new element to the string_list. The returned pointer can