git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Thiago Farina <tfransosi@gmail.com>
Date
Dec 14, 2010, 01:59 UTC
Message-ID
<996ab205063a5e0d70c064ed43633a4f651ea9ce.1292291971.git.tfransosi@gmail.com>
Signed-off-by: Thiago Farina <tfransosi@gmail.com>
---
 builtin/branch.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
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
Message 1 of 1 in “builtin/branch.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.”
  1. builtin/branch.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.Thiago Farina, Dec 14, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.