Re: [PATCH] string-list.h: Add STRING_LIST_INIT macro and make use of it.
- From
Alex Riesen <raa.lkml@gmail.com>
- Date
- Jun 28, 2010, 08:29 UTC
- Message-ID
- <AANLkTim14fh1RRSoYFK5uIqi8OrkB2zHahInDpO80gws@mail.gmail.com>
- In-Reply-To
- <7vbpawifwa.fsf@alter.siamese.dyndns.org>
On Sun, Jun 27, 2010 at 18:44, Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
> I think you need the attached on top to be more complete.
>
> But I wonder if this is worth it (not this "more complete", but your
> patch). We convert 16 or so instances of initialization for "no strdup"
> list, but there are about the same number of "strdup" instances still
> spelled out:
>
> $ git grep -e 'struct string_list [^ ]* = {.*'
> $ git grep -e 'struct string_list [^ ]* = {.*1'
>
> Wouldn't it be more sensible to use this instead?
>
> #define STRING_LIST_INIT(pleasedup) { NULL, 0, 0, (pleasedup) }
>This begs for using strdup(string-to-dup) in the macro argument, which will not compile with ancient compilers which don't allow code in an initializer.