diff options
author | Matheus Tavares <matheus.bernardino@usp.br> | 2021-05-04 13:27:28 -0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-05-05 12:25:25 +0900 |
commit | 96168827802b08c4adf2a036594ab235b2c5630f (patch) | |
tree | b1d6fc3ba702f01f3747a0beea7a6e4adc8a6d1e /read-cache.c | |
parent | parallel-checkout: add design documentation (diff) | |
download | tgif-96168827802b08c4adf2a036594ab235b2c5630f.tar.xz |
make_transient_cache_entry(): optionally alloc from mem_pool
Allow make_transient_cache_entry() to optionally receive a mem_pool
struct in which it should allocate the entry. This will be used in the
following patch, to store some transient entries which should persist
until parallel checkout finishes.
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/read-cache.c b/read-cache.c index 5a907af2fb..b46be4abcb 100644 --- a/read-cache.c +++ b/read-cache.c @@ -813,8 +813,11 @@ struct cache_entry *make_empty_cache_entry(struct index_state *istate, size_t le return mem_pool__ce_calloc(find_mem_pool(istate), len); } -struct cache_entry *make_empty_transient_cache_entry(size_t len) +struct cache_entry *make_empty_transient_cache_entry(size_t len, + struct mem_pool *ce_mem_pool) { + if (ce_mem_pool) + return mem_pool__ce_calloc(ce_mem_pool, len); return xcalloc(1, cache_entry_size(len)); } @@ -848,8 +851,11 @@ struct cache_entry *make_cache_entry(struct index_state *istate, return ret; } -struct cache_entry *make_transient_cache_entry(unsigned int mode, const struct object_id *oid, - const char *path, int stage) +struct cache_entry *make_transient_cache_entry(unsigned int mode, + const struct object_id *oid, + const char *path, + int stage, + struct mem_pool *ce_mem_pool) { struct cache_entry *ce; int len; @@ -860,7 +866,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode, const struct o } len = strlen(path); - ce = make_empty_transient_cache_entry(len); + ce = make_empty_transient_cache_entry(len, ce_mem_pool); oidcpy(&ce->oid, oid); memcpy(ce->name, path, len); |