Re: [PATCH 3/6] builtin-help: make it possible to exclude some commands in list_commands()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 28, 2008, 03:05 UTC
- Message-ID
- <7vljzmwvww.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <alpine.DEB.1.00.0807280442330.5526@eeepc-johanness>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 15 quoted lines
>> > +struct cmdnames {
>> > + int alloc;
>> > + int cnt;
>> > + struct cmdname {
>> > + size_t len;
>> > + char name[1];
>> > + } **names;
>> > +};
>>
>> I thought we do this kind of thing using FLEX_ARRAY macro. Is there any
>> reason its use is not appropriate here?
>
> I think that came up in the previous review round: the "name" member _is_
> NUL-terminated, but could have a ".exe" suffix. The "len" member has the
> length excluding ".exe".Sorry, but I do understand what you are trying to explain.
Marking the flexible member at the end as "last_member[FLEX_ARRAY]" is about a tiny bit of abstracting out how the exact decl syntax should look like depending on the compiler.
For example, we have:
struct git_attr {
struct git_attr *next;
unsigned h;
int attr_nr;
char name[FLEX_ARRAY];
};And h is _not_ the length of the name[] (it is a hash to help us find the entry quickly). Jjust like "len" is not the length of the name[] in your structure. In other words, marking as "last_member[FLEX_ARRAY]" does not have anything to do with what other fields you have in the same structure.
Hmm, am I missing a bigger picture somewhere else?