Skip to content

Commit 834d9eb

Browse files
tfarinagitster
authored andcommitted
builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.
Signed-off-by: Thiago Farina <tfransosi@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent fcbc0d8 commit 834d9eb

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

builtin/rm.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ static struct {
2020
const char **name;
2121
} list;
2222

23-
static void add_list(const char *name)
24-
{
25-
if (list.nr >= list.alloc) {
26-
list.alloc = alloc_nr(list.alloc);
27-
list.name = xrealloc(list.name, list.alloc * sizeof(const char *));
28-
}
29-
list.name[list.nr++] = name;
30-
}
31-
3223
static int check_local_mod(unsigned char *head, int index_only)
3324
{
3425
/*
@@ -182,7 +173,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
182173
struct cache_entry *ce = active_cache[i];
183174
if (!match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen))
184175
continue;
185-
add_list(ce->name);
176+
ALLOC_GROW(list.name, list.nr + 1, list.alloc);
177+
list.name[list.nr++] = ce->name;
186178
}
187179

188180
if (pathspec) {

0 commit comments

Comments
 (0)