string-list: spell all values out that are given to a string_list initializer

STRING_LIST_INIT_{NODUP,DUP} initializers list values only for earlier structure members, relying on the usual convention in C that the omitted members are initailized to 0, i.e. the former is expanded to the latter: struct string_list l = STRING_LIST_INIT_DUP; struct string_list l = { NULL, 0, 0, 1 }; and the last member that is not mentioned (i.e. 'cmp') is initialized to NULL. While there is nothing wrong in this construct, spelling out all the values where the macros are defined will serve also as a documentation, so let's do so. Signed-off-by: Tanay Abhra <tanayabh@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tanay Abhra committed Jun 3, 2014 at 02:13 UTC acb3d22264fd3736f95f71aa38e1d6fa01f5e9e1
2 files changed +4 -2
Documentation/technical/api-string-list.txt
+2
@@ -200,3 +200,5 @@ Represents the list itself.
200 You should not tamper with it.
201 . Setting the `strdup_strings` member to 1 will strdup() the strings
202 before adding them, see above.
203 +. The `compare_strings_fn` member is used to specify a custom compare
204 + function, otherwise `strcmp()` is used as the default function.
string-list.h
+2 -2
@@ -15,8 +15,8 @@ struct string_list {
15 compare_strings_fn cmp; /* NULL uses strcmp() */
16 };
17
18 -#define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0 }
19 -#define STRING_LIST_INIT_DUP { NULL, 0, 0, 1 }
18 +#define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0, NULL }
19 +#define STRING_LIST_INIT_DUP { NULL, 0, 0, 1, NULL }
20
21 void print_string_list(const struct string_list *p, const char *text);
22 void string_list_clear(struct string_list *list, int free_util);