36 unsigned int pre_alloc) :
37 esize(elem_size < sizeof(
Link) ? sizeof(
Link) : elem_size),
39 csize(esize*
n+sizeof(
Chunk)),
46 for (
unsigned int i=0; i<pre_alloc; i++)
57 operator delete((
void*) p);
86 void *p =
operator new(csize);
88 c->
mem =
static_cast<char*
>(p)+
sizeof(
Chunk);
95 char *last = &start[(
n-1)*esize];
97 for (
char *q = start; q<last; q += esize)
98 reinterpret_cast<Link*>(q)->next =
reinterpret_cast<Link*
>(q+esize);
99 reinterpret_cast<Link*
>(last)->next = NULL;
100 head =
reinterpret_cast<Link*
>(start);
void free(void *b)
Free an element.
void grow()
Allocate a new chunk.
expr expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c *expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 c
Represents a memory element.
MemPool(unsigned int elem_size, unsigned int n_elem, unsigned int pre_alloc=0)
Constructor. elem_size is the size of elements, n_elem is the number of elements per chunk...
Represents a memory chunk.
void * alloc()
Allocate a new element.