threads / patch / 26047

patchbuiltin/branch.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.

Subject: [PATCH] builtin/branch.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.

## tl;dr

One message between Dec 14, 2010 and Dec 14, 2010. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Thiago Farina· Dec 14, 2010, 01:59 UTC · lore
Signed-off-by: Thiago Farina <tfransosi@gmail.com>
---
 builtin/branch.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
Show changes to builtin/branch.c +1 −5
diff --git a/builtin/branch.c b/builtin/branch.c
index 807355a..7f34fad 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -314,11 +314,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
 	}
 
 	/* Resize buffer */
-	if (ref_list->index >= ref_list->alloc) {
-		ref_list->alloc = alloc_nr(ref_list->alloc);
-		ref_list->list = xrealloc(ref_list->list,
-				ref_list->alloc * sizeof(struct ref_item));
-	}
+	ALLOC_GROW(ref_list->list, ref_list->index + 1, ref_list->alloc);
 
 	/* Record the new item */
 	newitem = &(ref_list->list[ref_list->index++]);
-- 
1.7.3.2.343.g7d43d

← back to recent threads