Skip to content

Commit 25fd2f7

Browse files
peffgitster
authored andcommitted
Fix ALLOC_GROW calls with obsolete semantics
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1a15fed commit 25fd2f7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int
286286
if (cache_name_pos(pathname, len) >= 0)
287287
return NULL;
288288

289-
ALLOC_GROW(dir->entries, dir->nr, dir->alloc);
289+
ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
290290
return dir->entries[dir->nr++] = dir_entry_new(pathname, len);
291291
}
292292

@@ -295,7 +295,7 @@ struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname,
295295
if (cache_name_pos(pathname, len) >= 0)
296296
return NULL;
297297

298-
ALLOC_GROW(dir->ignored, dir->ignored_nr, dir->ignored_alloc);
298+
ALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc);
299299
return dir->ignored[dir->ignored_nr++] = dir_entry_new(pathname, len);
300300
}
301301

0 commit comments

Comments
 (0)