Thread (15 messages) flat view 15 messages, 1 author, 2016-06-15
DORMANTno replies

[PATCH v4 12/14] builtin/mktree.c: use ALLOC_GROW() in append_to_tree()

From: Dmitry S. Dolzhenko <hidden>
Date: 2016-06-15 23:00:10
Subsystem: the rest · Maintainer: Linus Torvalds

Helped-by: He Sun [off-list ref]
Signed-off-by: Dmitry S. Dolzhenko <redacted>
---
 builtin/mktree.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/builtin/mktree.c b/builtin/mktree.c
index f92ba40..a964d6b 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;
-- 
1.8.3.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help