Re: [PATCH 07/18] convert trivial cases to FLEX_ARRAY macros

2016-02-15 Thread Jeff King
On Mon, Feb 15, 2016 at 11:18:56PM -0500, Eric Sunshine wrote: > > diff --git a/builtin/reflog.c b/builtin/reflog.c > > @@ -408,13 +407,12 @@ static struct reflog_expire_cfg *find_cfg_ent(const > > char *pattern, size_t len) > > reflog_expire_cfg_tail = _expire_cfg; > > > >

Re: [PATCH 07/18] convert trivial cases to FLEX_ARRAY macros

2016-02-15 Thread Eric Sunshine
On Mon, Feb 15, 2016 at 10:36 PM, Jeff King wrote: > On Mon, Feb 15, 2016 at 10:26:26PM -0500, Jeff King wrote: >> We could do this on top of my series (I can also factor out the fix >> separately to go at the beginning if we don't want to hold the bugfix >> hostage). >> >> -- >8

Re: [PATCH 07/18] convert trivial cases to FLEX_ARRAY macros

2016-02-15 Thread Eric Sunshine
On Mon, Feb 15, 2016 at 10:15 PM, Jeff King wrote: > On Mon, Feb 15, 2016 at 09:17:05PM -0500, Eric Sunshine wrote: >> > - ent = xcalloc(1, (sizeof(*ent) + len)); >> > - memcpy(ent->pattern, pattern, len); >> > + FLEX_ALLOC_MEM(ent, pattern, pattern, len); >> >>

Re: [PATCH 07/18] convert trivial cases to FLEX_ARRAY macros

2016-02-15 Thread Jeff King
On Mon, Feb 15, 2016 at 10:26:26PM -0500, Jeff King wrote: > We could do this on top of my series (I can also factor out the fix > separately to go at the beginning if we don't want to hold the bugfix > hostage). > > -- >8 -- > Subject: [PATCH] reflog_expire_cfg: drop misleading "len" parameter

Re: [PATCH 07/18] convert trivial cases to FLEX_ARRAY macros

2016-02-15 Thread Jeff King
On Mon, Feb 15, 2016 at 10:15:54PM -0500, Jeff King wrote: > > Answering my own question: Looking at reflog_expire_config() and > > parse_config_key(), I gather that 'len' already accounts for the NUL, > > thus the new code is overallocating (which should not be a problem). > > Actually, I think

Re: [PATCH 07/18] convert trivial cases to FLEX_ARRAY macros

2016-02-15 Thread Jeff King
On Mon, Feb 15, 2016 at 09:17:05PM -0500, Eric Sunshine wrote: > > --- > > diff --git a/builtin/reflog.c b/builtin/reflog.c > > @@ -412,8 +410,7 @@ static struct reflog_expire_cfg *find_cfg_ent(const > > char *pattern, size_t len) > > !memcmp(ent->pattern, pattern, len)) > >

Re: [PATCH 07/18] convert trivial cases to FLEX_ARRAY macros

2016-02-15 Thread Eric Sunshine
On Mon, Feb 15, 2016 at 4:52 PM, Jeff King wrote: > Using FLEX_ARRAY macros reduces the amount of manual > computation size we have to do. It also ensures we don't > overflow size_t, and it makes sure we write the same number > of bytes that we allocated. > > Signed-off-by: Jeff

[PATCH 07/18] convert trivial cases to FLEX_ARRAY macros

2016-02-15 Thread Jeff King
Using FLEX_ARRAY macros reduces the amount of manual computation size we have to do. It also ensures we don't overflow size_t, and it makes sure we write the same number of bytes that we allocated. Signed-off-by: Jeff King --- attr.c | 4 +--- builtin/blame.c