{"thread":{"id":"8619","subject":"[PATCH] Fix ALLOC_GROW calls with obsolete semantics","startedAt":"2007-06-16T22:43:40Z","lastAt":"2007-06-16T22:43:40Z","messageCount":1,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"45194","messageId":"20070616224340.GA7362@coredump.intra.peff.net","threadId":"8619","inReplyTo":null,"subject":"[PATCH] Fix ALLOC_GROW calls with obsolete semantics","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-06-16T22:43:40Z","receivedAt":"2007-06-16T22:43:40Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"ALLOC_GROW now expects the 'nr' argument to be \"how much you\nwant\" and not \"how much you have\". This fixes all cases\nwhere we weren't previously adding anything to the 'nr'.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nThis is on top of the add-empty topic in next. Your other uses of\nALLOC_GROW are presumably OK since they were already adding in extra\nspace.\n\n dir.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex 98e24ad..8d8faf5 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -286,7 +286,7 @@ struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int\n \tif (cache_name_pos(pathname, len) >= 0)\n \t\treturn NULL;\n \n-\tALLOC_GROW(dir->entries, dir->nr, dir->alloc);\n+\tALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);\n \treturn dir->entries[dir->nr++] = dir_entry_new(pathname, len);\n }\n \n@@ -295,7 +295,7 @@ struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname,\n \tif (cache_name_pos(pathname, len) >= 0)\n \t\treturn NULL;\n \n-\tALLOC_GROW(dir->ignored, dir->ignored_nr, dir->ignored_alloc);\n+\tALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc);\n \treturn dir->ignored[dir->ignored_nr++] = dir_entry_new(pathname, len);\n }\n \n-- \n1.5.2.2.1012.ge05f4\n"}]}