summaryrefslogtreecommitdiff
path: root/string-list.h
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-07-01 10:51:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-07-01 19:32:22 (GMT)
commit770fedaf9fb156bd8c18da41770eac0cb63fba63 (patch)
tree7187ab68ef185ddc2f5351764e9dafa4ee6e2f2e /string-list.h
parentce93a4c6127abdf1ad9eacd537edd1c571a18e41 (diff)
downloadgit-770fedaf9fb156bd8c18da41770eac0cb63fba63.zip
git-770fedaf9fb156bd8c18da41770eac0cb63fba63.tar.gz
git-770fedaf9fb156bd8c18da41770eac0cb63fba63.tar.bz2
string-list.[ch]: add a string_list_init_{nodup,dup}()
In order to use the new "memcpy() a 'blank' struct on the stack" pattern for string_list_init(), and to make the macro initialization consistent with the function initialization introduce two new string_list_init_{nodup,dup}() functions. These are like the old string_list_init() when called with a false and true second argument, respectively. I think this not only makes things more consistent, but also easier to read. I often had to lookup what the ", 0)" or ", 1)" in these invocations meant, now it's right there in the function name, and corresponds to the macros. A subsequent commit will convert existing API users to this pattern, but as this is a very common API let's leave a compatibility function in place for later removal. This intermediate state also proves that the compatibility function works. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'string-list.h')
-rw-r--r--string-list.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/string-list.h b/string-list.h
index 521b9c0..0d6b469 100644
--- a/string-list.h
+++ b/string-list.h
@@ -97,8 +97,15 @@ struct string_list {
/* General functions which work with both sorted and unsorted lists. */
/**
- * Initialize the members of the string_list, set `strdup_strings`
- * member according to the value of the second parameter.
+ * Initialize the members of a string_list pointer in the same way as
+ * the corresponding `STRING_LIST_INIT_NODUP` and
+ * `STRING_LIST_INIT_DUP` macros.
+ */
+void string_list_init_nodup(struct string_list *list);
+void string_list_init_dup(struct string_list *list);
+
+/**
+ * TODO remove: For compatibility with any in-flight older API users
*/
void string_list_init(struct string_list *list, int strdup_strings);