From 0fd0e2417d383168b6a510f78c754298435a89ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 27 Nov 2010 01:17:44 +0700 Subject: [PATCH] dir.c: add free_excludes() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- dir.c | 12 ++++++++++++ dir.h | 1 + unpack-trees.c | 6 +----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/dir.c b/dir.c index b2dfb69eb..39eb7a3a4 100644 --- a/dir.c +++ b/dir.c @@ -223,6 +223,18 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size) return data; } +void free_excludes(struct exclude_list *el) +{ + int i; + + for (i = 0; i < el->nr; i++) + free(el->excludes[i]); + free(el->excludes); + + el->nr = 0; + el->excludes = NULL; +} + int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen, diff --git a/dir.h b/dir.h index 278d84cdf..ce5500829 100644 --- a/dir.h +++ b/dir.h @@ -78,6 +78,7 @@ extern int add_excludes_from_file_to_list(const char *fname, const char *base, i extern void add_excludes_from_file(struct dir_struct *, const char *fname); extern void add_exclude(const char *string, const char *base, int baselen, struct exclude_list *which); +extern void free_excludes(struct exclude_list *el); extern int file_exists(const char *); extern char *get_relative_cwd(char *buffer, int size, const char *dir); diff --git a/unpack-trees.c b/unpack-trees.c index 803445aa7..4d9241246 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -945,11 +945,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o->dst_index = o->result; done: - for (i = 0;i < el.nr;i++) - free(el.excludes[i]); - if (el.excludes) - free(el.excludes); - + free_excludes(&el); return ret; return_failed: -- 2.30.2