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 --- revision.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'revision.c') diff --git a/revision.c b/revision.c index b78733f508..99c859f797 100644 --- a/revision.c +++ b/revision.c @@ -154,7 +154,7 @@ static void paths_and_oids_insert(struct hashmap *map, entry = hashmap_get_entry(map, &key, ent, NULL); if (!entry) { - entry = xcalloc(1, sizeof(struct path_and_oids_entry)); + CALLOC_ARRAY(entry, 1); hashmap_entry_init(&entry->ent, hash); entry->path = xstrdup(key.path); oidset_init(&entry->trees, 16); @@ -1555,7 +1555,7 @@ void clear_ref_exclusion(struct string_list **ref_excludes_p) void add_ref_exclusion(struct string_list **ref_excludes_p, const char *exclude) { if (!*ref_excludes_p) { - *ref_excludes_p = xcalloc(1, sizeof(**ref_excludes_p)); + CALLOC_ARRAY(*ref_excludes_p, 1); (*ref_excludes_p)->strdup_strings = 1; } string_list_append(*ref_excludes_p, exclude); @@ -2929,7 +2929,7 @@ static struct merge_simplify_state *locate_simplify_state(struct rev_info *revs, st = lookup_decoration(&revs->merge_simplification, &commit->object); if (!st) { - st = xcalloc(1, sizeof(*st)); + CALLOC_ARRAY(st, 1); add_decoration(&revs->merge_simplification, &commit->object, st); } return st; -- cgit v1.2.3