]> git.ipfire.org Git - thirdparty/git.git/commit - string-list.h
string-list.[ch]: add a string_list_init_{nodup,dup}()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 1 Jul 2021 10:51:28 +0000 (12:51 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Jul 2021 19:32:22 +0000 (12:32 -0700)
commit770fedaf9fb156bd8c18da41770eac0cb63fba63
tree7187ab68ef185ddc2f5351764e9dafa4ee6e2f2e
parentce93a4c6127abdf1ad9eacd537edd1c571a18e41
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>
string-list.c
string-list.h