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>
This commit is contained in:
parent
d25430c5f8
commit
686a4a06b6
13
dir.c
13
dir.c
@ -144,11 +144,7 @@ void add_exclude(const char *string, const char *base,
|
|||||||
x->flags |= EXC_FLAG_NOWILDCARD;
|
x->flags |= EXC_FLAG_NOWILDCARD;
|
||||||
if (*string == '*' && no_wildcard(string+1))
|
if (*string == '*' && no_wildcard(string+1))
|
||||||
x->flags |= EXC_FLAG_ENDSWITH;
|
x->flags |= EXC_FLAG_ENDSWITH;
|
||||||
if (which->nr == which->alloc) {
|
ALLOC_GROW(which->excludes, which->nr + 1, which->alloc);
|
||||||
which->alloc = alloc_nr(which->alloc);
|
|
||||||
which->excludes = xrealloc(which->excludes,
|
|
||||||
which->alloc * sizeof(x));
|
|
||||||
}
|
|
||||||
which->excludes[which->nr++] = x;
|
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;
|
return dir->nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int file_exists(const char *f)
|
||||||
file_exists(const char *f)
|
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
return stat(f, &sb) == 0;
|
return stat(f, &sb) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user