summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-03-13 16:17:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-03-14 00:00:09 (GMT)
commitca56dadb4b65ccaeab809d80db80a312dc00941a (patch)
treefa027eb80d076ebf7be7c3ea69a92cf47e594a1c /remote.c
parentf1121499e6460e814ec3cffa0b18942ac529f768 (diff)
downloadgit-ca56dadb4b65ccaeab809d80db80a312dc00941a.zip
git-ca56dadb4b65ccaeab809d80db80a312dc00941a.tar.gz
git-ca56dadb4b65ccaeab809d80db80a312dc00941a.tar.bz2
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 'remote.c')
-rw-r--r--remote.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/remote.c b/remote.c
index c3f85c1..6d1e8d0 100644
--- a/remote.c
+++ b/remote.c
@@ -151,7 +151,7 @@ static struct remote *make_remote(const char *name, int len)
if (e)
return container_of(e, struct remote, ent);
- ret = xcalloc(1, sizeof(struct remote));
+ CALLOC_ARRAY(ret, 1);
ret->prune = -1; /* unspecified */
ret->prune_tags = -1; /* unspecified */
ret->name = xstrndup(name, len);
@@ -186,7 +186,7 @@ static struct branch *make_branch(const char *name, size_t len)
}
ALLOC_GROW(branches, branches_nr + 1, branches_alloc);
- ret = xcalloc(1, sizeof(struct branch));
+ CALLOC_ARRAY(ret, 1);
branches[branches_nr++] = ret;
ret->name = xstrndup(name, len);
ret->refname = xstrfmt("refs/heads/%s", ret->name);
@@ -207,7 +207,7 @@ static struct rewrite *make_rewrite(struct rewrites *r,
}
ALLOC_GROW(r->rewrite, r->rewrite_nr + 1, r->rewrite_alloc);
- ret = xcalloc(1, sizeof(struct rewrite));
+ CALLOC_ARRAY(ret, 1);
r->rewrite[r->rewrite_nr++] = ret;
ret->base = xstrndup(base, len);
ret->baselen = len;
@@ -1664,7 +1664,7 @@ static void set_merge(struct branch *ret)
remote = remote_get(ret->remote_name);
- ret->merge = xcalloc(ret->merge_nr, sizeof(*ret->merge));
+ CALLOC_ARRAY(ret->merge, ret->merge_nr);
for (i = 0; i < ret->merge_nr; i++) {
ret->merge[i] = xcalloc(1, sizeof(**ret->merge));
ret->merge[i]->src = xstrdup(ret->merge_name[i]);