From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, Jonathan Niedier <jrnieder@gmail.com>,
tfransosi@gmail.com
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 2/5] dir.c: add free_excludes()
Date: Sat, 27 Nov 2010 01:17:44 +0700 [thread overview]
Message-ID: <1290795467-7570-3-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1290795467-7570-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
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 b2dfb69..39eb7a3 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 278d84c..ce55008 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 803445a..4d92412 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:
--
1.7.3.2.316.gda8b3
next prev parent reply other threads:[~2010-11-26 18:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-26 18:17 [PATCH 0/5] Sparse checkout fixes Nguyễn Thái Ngọc Duy
2010-11-26 18:17 ` [PATCH 1/5] cache.h: remove surrounding brackes and realign CE_* constants Nguyễn Thái Ngọc Duy
2010-11-26 19:20 ` Thiago Farina
2010-11-27 6:22 ` [PATCH 1/5] cache.h: realign and use (1 << x) form for " Nguyễn Thái Ngọc Duy
2010-11-26 18:17 ` Nguyễn Thái Ngọc Duy [this message]
2010-11-26 18:17 ` [PATCH 3/5] unpack-trees: move all skip-worktree checks back to unpack_trees() Nguyễn Thái Ngọc Duy
2010-11-27 6:24 ` Nguyễn Thái Ngọc Duy
2010-11-26 18:17 ` [PATCH 4/5] unpack-trees: fix sparse checkout's "unable to match directories" Nguyễn Thái Ngọc Duy
2010-11-26 18:17 ` [PATCH 5/5] Revert "excluded_1(): support exclude files in index" Nguyễn Thái Ngọc Duy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1290795467-7570-3-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=tfransosi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.