* 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. */
| 36 | * head of the linked list. |
| 37 | */ |
| 38 | static 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 | |
| 61 | void mem_pool_init(struct mem_pool *pool, size_t initial_size) |
| 62 | { |
no test coverage detected