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>
Junio C Hamano committed
Nov 29, 2007 at 01:11 UTC
686a4a06b679a202430ca81267ad6505e92d839a
1 file changed
+4
-9
dir.c
+4
-9
@@ -144,11 +144,7 @@ void add_exclude(const char *string, const char *base,
144
x->flags |= EXC_FLAG_NOWILDCARD;
145
if (*string == '*' && no_wildcard(string+1))
146
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);
148
which->excludes[which->nr++] = x;
149
}
150
@@ -690,11 +686,10 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i
686
return dir->nr;
687
}
688
693
-int
694
-file_exists(const char *f)
689
+int file_exists(const char *f)
690
{
696
- struct stat sb;
697
- return stat(f, &sb) == 0;
691
+ struct stat sb;
692
+ return stat(f, &sb) == 0;
693
}
694
695
/*