summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorLibravatar René Scharfe <l.s.r@web.de>2021-03-13 17:17:22 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-03-13 16:00:09 -0800
commitca56dadb4b65ccaeab809d80db80a312dc00941a (patch)
treefa027eb80d076ebf7be7c3ea69a92cf47e594a1c /read-cache.c
parentgit-compat-util.h: drop trailing semicolon from macro definition (diff)
downloadtgif-ca56dadb4b65ccaeab809d80db80a312dc00941a.tar.xz
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>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/read-cache.c b/read-cache.c
index 1e9a50c6c7..c8d12eaa3c 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2097,7 +2097,7 @@ static unsigned long load_cache_entries_threaded(struct index_state *istate, con
/* ensure we have no more threads than we have blocks to process */
if (nr_threads > ieot->nr)
nr_threads = ieot->nr;
- data = xcalloc(nr_threads, sizeof(*data));
+ CALLOC_ARRAY(data, nr_threads);
offset = ieot_start = 0;
ieot_blocks = DIV_ROUND_UP(ieot->nr, nr_threads);
@@ -2199,7 +2199,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
istate->version = ntohl(hdr->hdr_version);
istate->cache_nr = ntohl(hdr->hdr_entries);
istate->cache_alloc = alloc_nr(istate->cache_nr);
- istate->cache = xcalloc(istate->cache_alloc, sizeof(*istate->cache));
+ CALLOC_ARRAY(istate->cache, istate->cache_alloc);
istate->initialized = 1;
p.istate = istate;
@@ -2326,7 +2326,7 @@ int read_index_from(struct index_state *istate, const char *path,
if (split_index->base)
discard_index(split_index->base);
else
- split_index->base = xcalloc(1, sizeof(*split_index->base));
+ CALLOC_ARRAY(split_index->base, 1);
base_oid_hex = oid_to_hex(&split_index->base_oid);
base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
@@ -3427,7 +3427,7 @@ void stat_validity_update(struct stat_validity *sv, int fd)
stat_validity_clear(sv);
else {
if (!sv->sd)
- sv->sd = xcalloc(1, sizeof(struct stat_data));
+ CALLOC_ARRAY(sv->sd, 1);
fill_stat_data(sv->sd, &st);
}
}