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

[PATCH] attr.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.

From
Thiago Farina <tfransosi@gmail.com>
Date
Dec 22, 2010, 00:35 UTC
Message-ID
<3c6870c390110bd1bf5c5f59a99928afc86cf188.1292978127.git.tfransosi@gmail.com>
Signed-off-by: Thiago Farina <tfransosi@gmail.com>
---
 attr.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/attr.c b/attr.c
index 6aff695..fdc0515 100644
--- a/attr.c
+++ b/attr.c
@@ -305,12 +305,8 @@ static void handle_attr_line(struct attr_stack *res,
 	a = parse_attr_line(line, src, lineno, macro_ok);
 	if (!a)
 		return;
-	if (res->alloc <= res->num_matches) {
-		res->alloc = alloc_nr(res->num_matches);
-		res->attrs = xrealloc(res->attrs,
-				      sizeof(struct match_attr *) *
-				      res->alloc);
-	}
+
+	ALLOC_GROW(res->attrs, res->num_matches + 1, res->alloc);
 	res->attrs[res->num_matches++] = a;
 }
 
-- 
1.7.3.2.343.g7d43d
Next: Junio C Hamano
Message 1 of 3 in “attr.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.”
  1. attr.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.Thiago Farina, Dec 22, 2010
  2. Junio C HamanoDec 22, 2010
  3. Thiago FarinaDec 22, 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.