replace: avoid using die() to indicate a bug
[git/debian.git] / mem-pool.h
blob829ad58ecfc48ce7ebbd707e833e933c87eb0d44
1 #ifndef MEM_POOL_H
2 #define MEM_POOL_H
4 struct mp_block {
5 struct mp_block *next_block;
6 char *next_free;
7 char *end;
8 uintmax_t space[FLEX_ARRAY]; /* more */
9 };
11 struct mem_pool {
12 struct mp_block *mp_block;
15 * The amount of available memory to grow the pool by.
16 * This size does not include the overhead for the mp_block.
18 size_t block_alloc;
20 /* The total amount of memory allocated by the pool. */
21 size_t pool_alloc;
25 * Alloc memory from the mem_pool.
27 void *mem_pool_alloc(struct mem_pool *pool, size_t len);
30 * Allocate and zero memory from the memory pool.
32 void *mem_pool_calloc(struct mem_pool *pool, size_t count, size_t size);
34 #endif