2 * Sherlock Library -- Memory Pools
4 * (c) 1997--2003 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
10 #ifndef _SHERLOCK_POOLS_H
11 #define _SHERLOCK_POOLS_H
14 #define POOL_ALIGN CPU_STRUCT_ALIGN
21 struct memchunk *first, *current, **plast;
22 struct memchunk *first_large;
23 uns chunk_size, threshold;
26 struct mempool *mp_new(uns);
27 void mp_delete(struct mempool *);
28 void mp_flush(struct mempool *);
29 void *mp_alloc(struct mempool *, uns);
30 void *mp_alloc_zero(struct mempool *, uns);
32 static inline void *mp_alloc_fast(struct mempool *p, uns l)
34 byte *f = (void *) (((uintptr_t) p->free + POOL_ALIGN - 1) & ~((uintptr_t) POOL_ALIGN - 1));
37 return mp_alloc(p, l);
42 static inline void *mp_alloc_fast_noalign(struct mempool *p, uns l)
47 return mp_alloc(p, l);
53 mp_start_string(struct mempool *p, uns l)
55 ASSERT(l <= p->chunk_size);
56 return mp_alloc(p, l);
60 mp_end_string(struct mempool *p, void *stop)