MCPcopy Index your code
hub / github.com/git/git / mem_pool_alloc

Function mem_pool_alloc

mem-pool.c:90–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90void *mem_pool_alloc(struct mem_pool *pool, size_t len)
91{
92 struct mp_block *p = NULL;
93 void *r;
94
95 len = DIV_ROUND_UP(len, GIT_MAX_ALIGNMENT) * GIT_MAX_ALIGNMENT;
96
97 if (pool->mp_block &&
98 pool->mp_block->end - pool->mp_block->next_free >= len)
99 p = pool->mp_block;
100
101 if (!p) {
102 if (len >= (pool->block_alloc / 2))
103 p = mem_pool_alloc_block(pool, len, pool->mp_block);
104 else
105 p = mem_pool_alloc_block(pool, pool->block_alloc, NULL);
106 }
107
108 r = p->next_free;
109 p->next_free += len;
110 return r;
111}
112
113static char *mem_pool_strvfmt(struct mem_pool *pool, const char *fmt,
114 va_list ap)

Callers 15

unique_pathFunction · 0.85
process_entryFunction · 0.85
mem_pool_strvfmtFunction · 0.85
mem_pool_callocFunction · 0.85
mem_pool_strdupFunction · 0.85
mem_pool_strndupFunction · 0.85
insert_file_tableFunction · 0.85
oidtree_insertFunction · 0.85
create_entryFunction · 0.85
mem_pool__ce_allocFunction · 0.85

Calls 1

mem_pool_alloc_blockFunction · 0.85

Tested by 1

sort_stdinFunction · 0.68