diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-07-16 17:42:52 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-07-16 17:42:53 -0700 |
commit | bd4232fac3319890429ec303e2f7c3d287c8eaa3 (patch) | |
tree | b5032aca9cdafb5812801f2868cabddc23e2052a /string-list.c | |
parent | 832a239b72779e97b09943d77b9097ed8376e18e (diff) | |
parent | bc40dfb10a06612813a3f9b733d65af0732208b2 (diff) |
Merge branch 'ab/struct-init'
Code cleanup around struct_type_init() functions.
* ab/struct-init:
string-list.h users: change to use *_{nodup,dup}()
string-list.[ch]: add a string_list_init_{nodup,dup}()
dir.[ch]: replace dir_init() with DIR_INIT
*.c *_init(): define in terms of corresponding *_INIT macro
*.h: move some *_INIT to designated initializers
Diffstat (limited to 'string-list.c')
-rw-r--r-- | string-list.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/string-list.c b/string-list.c index a917955fbd..43576ad126 100644 --- a/string-list.c +++ b/string-list.c @@ -1,10 +1,24 @@ #include "cache.h" #include "string-list.h" +void string_list_init_nodup(struct string_list *list) +{ + struct string_list blank = STRING_LIST_INIT_NODUP; + memcpy(list, &blank, sizeof(*list)); +} + +void string_list_init_dup(struct string_list *list) +{ + struct string_list blank = STRING_LIST_INIT_DUP; + memcpy(list, &blank, sizeof(*list)); +} + void string_list_init(struct string_list *list, int strdup_strings) { - memset(list, 0, sizeof(*list)); - list->strdup_strings = strdup_strings; + if (strdup_strings) + string_list_init_dup(list); + else + string_list_init_nodup(list); } /* if there is no exact match, point to the index where the entry could be |