use CALLOC_ARRAY
Add and apply a semantic patch for converting code that open-codes CALLOC_ARRAY to use it instead. It shortens the code and infers the element size automatically. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
f1121499e6
commit
ca56dadb4b
@ -5171,7 +5171,7 @@ void todo_list_add_exec_commands(struct todo_list *todo_list,
|
||||
int i, insert, nr = 0, alloc = 0;
|
||||
struct todo_item *items = NULL, *base_items = NULL;
|
||||
|
||||
base_items = xcalloc(commands->nr, sizeof(struct todo_item));
|
||||
CALLOC_ARRAY(base_items, commands->nr);
|
||||
for (i = 0; i < commands->nr; i++) {
|
||||
size_t command_len = strlen(commands->items[i].string);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user