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>
This commit is contained in:
parent
3a7fa03db9
commit
66d9f38bc7
@ -23,10 +23,7 @@ static void append_to_tree(unsigned mode, unsigned char *sha1, char *path)
|
|||||||
if (strchr(path, '/'))
|
if (strchr(path, '/'))
|
||||||
die("path %s contains slash", path);
|
die("path %s contains slash", path);
|
||||||
|
|
||||||
if (alloc <= used) {
|
ALLOC_GROW(entries, used + 1, alloc);
|
||||||
alloc = alloc_nr(used);
|
|
||||||
entries = xrealloc(entries, sizeof(*entries) * alloc);
|
|
||||||
}
|
|
||||||
ent = entries[used++] = xmalloc(sizeof(**entries) + len + 1);
|
ent = entries[used++] = xmalloc(sizeof(**entries) + len + 1);
|
||||||
ent->mode = mode;
|
ent->mode = mode;
|
||||||
ent->len = len;
|
ent->len = len;
|
||||||
|
Loading…
Reference in New Issue
Block a user