From: Alex Riesen <raa.lkml@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Thiago Farina <tfransosi@gmail.com>,
git@vger.kernel.org, jrnieder@gmail.com, srabbelier@gmail.com
Subject: Re: [PATCH] string-list.h: Add STRING_LIST_INIT macro and make use of it.
Date: Tue, 29 Jun 2010 10:33:51 +0200 [thread overview]
Message-ID: <AANLkTinXCkX2tXFTlOSLShXMpsnpaNX0LoYGaml0sgN5@mail.gmail.com> (raw)
In-Reply-To: <7v4ogmcs1u.fsf@alter.siamese.dyndns.org>
On Tue, Jun 29, 2010 at 07:43, Junio C Hamano <gitster@pobox.com> wrote:
>>>
>>> #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.
>
> Err, one of us must be confused.
>
> I was suggesting to rewrite things like these, found in builtin/remote.c
> (add and rm):
>
> struct string_list track = { NULL, 0, 0, 0 };
> struct string_list branches = { NULL, 0, 0, 1 };
>
That must be me, again. Didn't bother to check the string_list definition
and naively assumed the pleasedup was for an initialization string. I
thought that depending on usage the caller may wish to either copy it
or leave the string_list referncing the original. Which cannot be the case
with string_list, indeed.
BTW, now that I took a look at it... The iteration over string_list
items looks a little overengineered. At least from the point of
view of the existing users of the feature. Wouldn't a simple loop
be just as simple to use (if not simplier) and faster (no uninlineable
function calls and argument preparation and passing needed)?
#define string_list_foreach(item,list) \
for (item = (list)->items; item < (list)->items + (list)->nr; ++item)
next prev parent reply other threads:[~2010-06-29 8:34 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-26 22:34 [PATCH] string-list.h: Add STRING_LIST_INIT macro and make use of it Thiago Farina
2010-06-26 22:53 ` Sverre Rabbelier
2010-06-26 23:04 ` Jonathan Nieder
2010-06-26 23:44 ` Thiago Farina
2010-06-26 23:40 ` Thiago Farina
2010-06-26 23:47 ` Thiago Farina
2010-06-27 16:44 ` Junio C Hamano
2010-06-28 8:29 ` Alex Riesen
2010-06-29 5:43 ` Junio C Hamano
2010-06-29 8:15 ` Peter Kjellerstedt
2010-06-29 8:33 ` Alex Riesen [this message]
2010-07-02 19:15 ` [PATCH] string_list: " Thiago Farina
2010-07-02 19:30 ` Jonathan Nieder
2010-07-02 19:47 ` Thiago Farina
2010-07-02 20:22 ` Jonathan Nieder
2010-07-04 19:46 ` Thiago Farina
2010-07-07 15:19 ` Jonathan Nieder
2010-07-07 16:55 ` Junio C Hamano
2010-07-10 5:01 ` Thiago Farina
2010-07-10 22:41 ` Jonathan Nieder
2010-08-19 13:28 ` Thiago Farina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTinXCkX2tXFTlOSLShXMpsnpaNX0LoYGaml0sgN5@mail.gmail.com \
--to=raa.lkml@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=srabbelier@gmail.com \
--cc=tfransosi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).