From: Dmitry S. Dolzhenko Date: Mon, 3 Mar 2014 22:32:00 +0000 (+0400) Subject: builtin/mktree.c: use ALLOC_GROW() in append_to_tree() X-Git-Tag: v2.0.0-rc0~97^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=66d9f38bc72b4415046704697f3d3898afbce73a;p=git builtin/mktree.c: use ALLOC_GROW() in append_to_tree() Helped-by: He Sun Signed-off-by: Dmitry S. Dolzhenko Signed-off-by: Junio C Hamano --- diff --git a/builtin/mktree.c b/builtin/mktree.c index f92ba404ab..a964d6be52 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -23,10 +23,7 @@ static void append_to_tree(unsigned mode, unsigned char *sha1, char *path) if (strchr(path, '/')) die("path %s contains slash", path); - if (alloc <= used) { - alloc = alloc_nr(used); - entries = xrealloc(entries, sizeof(*entries) * alloc); - } + ALLOC_GROW(entries, used + 1, alloc); ent = entries[used++] = xmalloc(sizeof(**entries) + len + 1); ent->mode = mode; ent->len = len;