Skip to content

Commit 0e187d7

Browse files
rscharfegitster
authored andcommitted
run-command: use ALLOC_ARRAY
Use the macro ALLOC_ARRAY to allocate an array. This is shorter and easier, as it automatically infers the size of elements. Patch generated with Coccinelle and contrib/coccinelle/array.cocci. Signeg-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4010f1d commit 0e187d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

run-command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static char **prep_childenv(const char *const *deltaenv)
452452
}
453453

454454
/* Create an array of 'char *' to be used as the childenv */
455-
childenv = xmalloc((env.nr + 1) * sizeof(char *));
455+
ALLOC_ARRAY(childenv, env.nr + 1);
456456
for (i = 0; i < env.nr; i++)
457457
childenv[i] = env.items[i].util;
458458
childenv[env.nr] = NULL;

0 commit comments

Comments
 (0)