unpack-trees: factor out dup_entry
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.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
21a6b9fa42
commit
a33bd4d34d
@ -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);
|
ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
|
static struct cache_entry *dup_entry(const struct cache_entry *ce)
|
||||||
unsigned int set, unsigned int clear)
|
|
||||||
{
|
{
|
||||||
unsigned int size = ce_size(ce);
|
unsigned int size = ce_size(ce);
|
||||||
struct cache_entry *new = xmalloc(size);
|
struct cache_entry *new = xmalloc(size);
|
||||||
|
|
||||||
memcpy(new, ce, 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user