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:
René Scharfe
2021-03-13 17:17:22 +01:00
committed by Junio C Hamano
parent f1121499e6
commit ca56dadb4b
88 changed files with 190 additions and 188 deletions

View File

@ -516,7 +516,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
return NULL;
count = st.st_size / (the_hash_algo->hexsz + 1);
oids = xcalloc(count, sizeof(struct object_id));
CALLOC_ARRAY(oids, count);
prepare_alt_odb(r);
@ -2238,7 +2238,7 @@ int write_commit_graph(struct object_directory *odb,
if (!commit_graph_compatible(the_repository))
return 0;
ctx = xcalloc(1, sizeof(struct write_commit_graph_context));
CALLOC_ARRAY(ctx, 1);
ctx->r = the_repository;
ctx->odb = odb;
ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;