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

Function mem_pool_alloc_block

mem-pool.c:38–59  ·  view source on GitHub ↗

* Allocate a new mp_block and insert it after the block specified in * `insert_after`. If `insert_after` is NULL, then insert block at the * head of the linked list. */

Source from the content-addressed store, hash-verified

36 * head of the linked list.
37 */
38static struct mp_block *mem_pool_alloc_block(struct mem_pool *pool,
39 size_t block_alloc,
40 struct mp_block *insert_after)
41{
42 struct mp_block *p;
43
44 pool->pool_alloc += sizeof(struct mp_block) + block_alloc;
45 p = xmalloc(st_add(sizeof(struct mp_block), block_alloc));
46
47 p->next_free = (char *)p->space;
48 p->end = p->next_free + block_alloc;
49
50 if (insert_after) {
51 p->next_block = insert_after->next_block;
52 insert_after->next_block = p;
53 } else {
54 p->next_block = pool->mp_block;
55 pool->mp_block = p;
56 }
57
58 return p;
59}
60
61void mem_pool_init(struct mem_pool *pool, size_t initial_size)
62{

Callers 2

mem_pool_initFunction · 0.85
mem_pool_allocFunction · 0.85

Calls 2

st_addFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected