dir.c: minor clean-up
authorJunio C Hamano <gitster@pobox.com>
Thu, 29 Nov 2007 09:11:46 +0000 (01:11 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 29 Nov 2007 09:11:46 +0000 (01:11 -0800)
Replace handcrafted reallocation with ALLOC_GROW().
Reindent "file_exists()" helper function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c

diff --git a/dir.c b/dir.c
index 225fdfb52c432b7af1af1cdf9aa9a31f8022e3ec..7c97483761d5cc676907b5bdb2cfcb96382a9514 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -144,11 +144,7 @@ void add_exclude(const char *string, const char *base,
                x->flags |= EXC_FLAG_NOWILDCARD;
        if (*string == '*' && no_wildcard(string+1))
                x->flags |= EXC_FLAG_ENDSWITH;
-       if (which->nr == which->alloc) {
-               which->alloc = alloc_nr(which->alloc);
-               which->excludes = xrealloc(which->excludes,
-                                          which->alloc * sizeof(x));
-       }
+       ALLOC_GROW(which->excludes, which->nr + 1, which->alloc);
        which->excludes[which->nr++] = x;
 }
 
@@ -690,11 +686,10 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i
        return dir->nr;
 }
 
-int
-file_exists(const char *f)
+int file_exists(const char *f)
 {
-  struct stat sb;
-  return stat(f, &sb) == 0;
+       struct stat sb;
+       return stat(f, &sb) == 0;
 }
 
 /*