Skip to content

Commit 686a4a0

Browse files
committed
dir.c: minor clean-up
Replace handcrafted reallocation with ALLOC_GROW(). Reindent "file_exists()" helper function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d25430c commit 686a4a0

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

dir.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ void add_exclude(const char *string, const char *base,
144144
x->flags |= EXC_FLAG_NOWILDCARD;
145145
if (*string == '*' && no_wildcard(string+1))
146146
x->flags |= EXC_FLAG_ENDSWITH;
147-
if (which->nr == which->alloc) {
148-
which->alloc = alloc_nr(which->alloc);
149-
which->excludes = xrealloc(which->excludes,
150-
which->alloc * sizeof(x));
151-
}
147+
ALLOC_GROW(which->excludes, which->nr + 1, which->alloc);
152148
which->excludes[which->nr++] = x;
153149
}
154150

@@ -690,11 +686,10 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i
690686
return dir->nr;
691687
}
692688

693-
int
694-
file_exists(const char *f)
689+
int file_exists(const char *f)
695690
{
696-
struct stat sb;
697-
return stat(f, &sb) == 0;
691+
struct stat sb;
692+
return stat(f, &sb) == 0;
698693
}
699694

700695
/*

0 commit comments

Comments
 (0)