Code

dir.c: add free_excludes()
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Fri, 26 Nov 2010 18:17:44 +0000 (01:17 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Nov 2010 21:34:55 +0000 (13:34 -0800)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c
dir.h
unpack-trees.c

diff --git a/dir.c b/dir.c
index b2dfb69eb5606a7538cc5e1876a91f703ec4969c..39eb7a3a4f9d26f2a5944f233cbe1d358a9b6440 100644 (file)
--- 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 278d84cdf7df01c33a45e6dc9c20592cecff9d85..ce55008298bc8fc0e3bef1f8e076787bda90d5a9 100644 (file)
--- 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);
index 803445aa7be140c3707bcebc72aaf6fc6af45e4b..4d92412469ef99ff9320fdf0594b4361049fc13e 100644 (file)
@@ -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: