git-2.22.0/mem-pool.c
/*
 * 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.
 */
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.
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 .
static struct mp_block *mem_pool_alloc_block(struct mem_pool *mem_pool, size_t block_alloc, struct mp_block *insert_after)
{
	struct mp_block *p;
	mem_pool->pool_alloc += sizeof(struct mp_block) + block_alloc;
	p = xmalloc(st_add(sizeof(struct mp_block), block_alloc));
	p->next_free = (char *)p->space;
	p->end = p->next_free + block_alloc;
	if (insert_after) {
		p->next_block = insert_after->next_block;
		insert_after->next_block = p;
	} else {
		p->next_block = mem_pool->mp_block;
		mem_pool->mp_block = p;
	}
	return p;
}
static struct mp_block * mem_pool_alloc_block ( struct mem_pool * mem_pool , size_t block_alloc , struct mp_block * insert_after ) { struct mp_block * p ; mem_pool -> pool_alloc += sizeof ( struct mp_block ) + block_alloc ; p = xmalloc ( st_add ( sizeof ( struct mp_block ) , block_alloc ) ) ; p -> next_free = ( char * ) p -> space ; p -> end = p -> next_free + block_alloc ; if ( insert_after ) { p -> next_block = insert_after -> next_block ; insert_after -> next_block = p ; } else { p -> next_block = mem_pool -> mp_block ; mem_pool -> mp_block = p ; } return p ; }
Allocate a new mp_block and insert it after the block specified in
 `insert_after`.
Allocate a new mp_block and insert it after the block specified in ` insert_after ` .