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 <rene.scha...@lsrfire.ath.cx>
 unpack-trees.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index ede4299..e8b4cc1 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);

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to