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

[PATCH] Fix ALLOC_GROW calls with obsolete semantics

From
Jeff King <peff@peff.net>
Date
Jun 16, 2007, 22:43 UTC
Message-ID
<20070616224340.GA7362@coredump.intra.peff.net>

ALLOC_GROW now expects the 'nr' argument to be "how much you want" and not "how much you have". This fixes all cases where we weren't previously adding anything to the 'nr'.

Signed-off-by: Jeff King <peff@peff.net>
---
This is on top of the add-empty topic in next. Your other uses of
ALLOC_GROW are presumably OK since they were already adding in extra
space.
 dir.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dir.c b/dir.c
index 98e24ad..8d8faf5 100644
--- a/dir.c
+++ b/dir.c
@@ -286,7 +286,7 @@ struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int
 	if (cache_name_pos(pathname, len) >= 0)
 		return NULL;
 
-	ALLOC_GROW(dir->entries, dir->nr, dir->alloc);
+	ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
 	return dir->entries[dir->nr++] = dir_entry_new(pathname, len);
 }
 
@@ -295,7 +295,7 @@ struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname,
 	if (cache_name_pos(pathname, len) >= 0)
 		return NULL;
 
-	ALLOC_GROW(dir->ignored, dir->ignored_nr, dir->ignored_alloc);
+	ALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc);
 	return dir->ignored[dir->ignored_nr++] = dir_entry_new(pathname, len);
 }
 
-- 
1.5.2.2.1012.ge05f4
Message 1 of 1 in “Fix ALLOC_GROW calls with obsolete semantics”
  1. Fix ALLOC_GROW calls with obsolete semanticsJeff King, Jun 16, 2007

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.