From ca56dadb4b65ccaeab809d80db80a312dc00941a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 13 Mar 2021 17:17:22 +0100 Subject: use CALLOC_ARRAY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- dir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'dir.c') diff --git a/dir.c b/dir.c index fd8aa7c40f..19c2fa239b 100644 --- a/dir.c +++ b/dir.c @@ -1488,7 +1488,7 @@ static void prep_exclude(struct dir_struct *dir, const char *cp; struct oid_stat oid_stat; - stk = xcalloc(1, sizeof(*stk)); + CALLOC_ARRAY(stk, 1); if (current < 0) { cp = base; current = 0; @@ -3162,7 +3162,7 @@ void write_untracked_extension(struct strbuf *out, struct untracked_cache *untra int varint_len; const unsigned hashsz = the_hash_algo->rawsz; - ouc = xcalloc(1, sizeof(*ouc)); + CALLOC_ARRAY(ouc, 1); stat_data_to_disk(&ouc->info_exclude_stat, &untracked->ss_info_exclude.stat); stat_data_to_disk(&ouc->excludes_file_stat, &untracked->ss_excludes_file.stat); ouc->dir_flags = htonl(untracked->dir_flags); @@ -3373,7 +3373,7 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long if (next + exclude_per_dir_offset + 1 > end) return NULL; - uc = xcalloc(1, sizeof(*uc)); + CALLOC_ARRAY(uc, 1); strbuf_init(&uc->ident, ident_len); strbuf_add(&uc->ident, ident, ident_len); load_oid_stat(&uc->ss_info_exclude, -- cgit v1.2.3