mirror of
https://github.com/git/git.git
synced 2024-11-24 10:26:17 +08:00
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:
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user