builtin/mktree.c: use ALLOC_GROW() in append_to_tree()
Helped-by: He Sun <sunheehnus@gmail.com> Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Dmitry S. Dolzhenko committed
Mar 4, 2014 at 02:32 UTC
66d9f38bc72b4415046704697f3d3898afbce73a
1 file changed
+1
-4
builtin/mktree.c
+1
-4
@@ -23,10 +23,7 @@ static void append_to_tree(unsigned mode, unsigned char *sha1, char *path)
23
if (strchr(path, '/'))
24
die("path %s contains slash", path);
25
26
- if (alloc <= used) {
27
- alloc = alloc_nr(used);
28
- entries = xrealloc(entries, sizeof(*entries) * alloc);
29
- }
26
+ ALLOC_GROW(entries, used + 1, alloc);
27
ent = entries[used++] = xmalloc(sizeof(**entries) + len + 1);
28
ent->mode = mode;
29
ent->len = len;