2 * Sherlock Library -- Memory Pools
4 * (c) 1997--2001 Martin Mares <mj@ucw.cz>
7 #ifndef _SHERLOCK_POOLS_H
8 #define _SHERLOCK_POOLS_H
11 #define POOL_ALIGN CPU_STRUCT_ALIGN
16 struct memchunk *first, *current, **plast;
17 struct memchunk *first_large;
18 uns chunk_size, threshold;
21 struct mempool *mp_new(uns);
22 void mp_delete(struct mempool *);
23 void mp_flush(struct mempool *);
24 void *mp_alloc(struct mempool *, uns);
25 void *mp_alloc_zero(struct mempool *, uns);
27 static inline void *mp_alloc_fast(struct mempool *p, uns l)
29 byte *f = (void *) (((uns) p->free + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1));
32 return mp_alloc(p, l);
37 static inline void *mp_alloc_fast_noalign(struct mempool *p, uns l)
42 return mp_alloc(p, l);