Re: [PATCH 05/18] convert trivial cases to ALLOC_ARRAY

2016-02-15 Thread Jeff King
On Mon, Feb 15, 2016 at 11:32:25PM -0500, Eric Sunshine wrote: > On Mon, Feb 15, 2016 at 11:23 PM, Jeff King wrote: > > On Mon, Feb 15, 2016 at 11:22:12PM -0500, Eric Sunshine wrote: > >> On Mon, Feb 15, 2016 at 4:51 PM, Jeff King wrote: > >> > - path =

Re: [PATCH 05/18] convert trivial cases to ALLOC_ARRAY

2016-02-15 Thread Eric Sunshine
On Mon, Feb 15, 2016 at 11:23 PM, Jeff King wrote: > On Mon, Feb 15, 2016 at 11:22:12PM -0500, Eric Sunshine wrote: >> On Mon, Feb 15, 2016 at 4:51 PM, Jeff King wrote: >> > - path = xmalloc((n+1)*sizeof(char *)); >> > + ALLOC_ARRAY(path, n+1); >> >>

Re: [PATCH 05/18] convert trivial cases to ALLOC_ARRAY

2016-02-15 Thread Jeff King
On Mon, Feb 15, 2016 at 11:22:12PM -0500, Eric Sunshine wrote: > On Mon, Feb 15, 2016 at 4:51 PM, Jeff King wrote: > > Each of these cases can be converted to use ALLOC_ARRAY or > > REALLOC_ARRAY, which has two advantages: > > > > 1. It automatically checks the array-size

Re: [PATCH 05/18] convert trivial cases to ALLOC_ARRAY

2016-02-15 Thread Eric Sunshine
On Mon, Feb 15, 2016 at 4:51 PM, Jeff King wrote: > Each of these cases can be converted to use ALLOC_ARRAY or > REALLOC_ARRAY, which has two advantages: > > 1. It automatically checks the array-size multiplication > for overflow. > > 2. It always uses sizeof(*array) for

[PATCH 05/18] convert trivial cases to ALLOC_ARRAY

2016-02-15 Thread Jeff King
Each of these cases can be converted to use ALLOC_ARRAY or REALLOC_ARRAY, which has two advantages: 1. It automatically checks the array-size multiplication for overflow. 2. It always uses sizeof(*array) for the element-size, so that it can never go out of sync with the declared