From a33bd4d34def15d12372aeb8c59a7465416f9f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sun, 2 Jun 2013 17:46:53 +0200 Subject: unpack-trees: factor out dup_entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While we're add it, mark the struct cache_entry pointer of add_entry const because we only read from it and this allows callers to pass in const pointers. Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- unpack-trees.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'unpack-trees.c') diff --git a/unpack-trees.c b/unpack-trees.c index ede4299b8..e8b4cc198 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -116,14 +116,20 @@ static void do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE); } -static void add_entry(struct unpack_trees_options *o, struct cache_entry *ce, - unsigned int set, unsigned int clear) +static struct cache_entry *dup_entry(const struct cache_entry *ce) { unsigned int size = ce_size(ce); struct cache_entry *new = xmalloc(size); memcpy(new, ce, size); - do_add_entry(o, new, set, clear); + return new; +} + +static void add_entry(struct unpack_trees_options *o, + const struct cache_entry *ce, + unsigned int set, unsigned int clear) +{ + do_add_entry(o, dup_entry(ce), set, clear); } /* -- cgit v1.2.1