5 #include <mware/list.h>
7 #define EXTERN_POOL(name) \
10 #define DECLARE_POOL_WITH_STORAGE(name, type, num, storage) \
11 static type name##_items[num]; \
13 INLINE void name##_init(void (*init_func)(type*)) \
17 for (i=0;i<countof(name##_items);++i) \
19 if (init_func) init_func(&name##_items[i]); \
20 ADDTAIL(&name, (Node*)&name##_items[i]); \
23 INLINE void name##_init(void (*init_func)(type*)) \
26 #define DECLARE_POOL(name, type, num) \
27 DECLARE_POOL_WITH_STORAGE(name, type, num, List)
29 #define DECLARE_POOL_STATIC(name, type, num) \
30 DECLARE_POOL_WITH_STORAGE(name, type, num, static List)
32 #define pool_init(name, init_func) (*(name##_init))(init_func)
33 #define pool_alloc(name) REMHEAD(name)
34 #define pool_free(name, elem) ADDHEAD(name, (Node*)elem)
35 #define pool_empty(name) ISLISTEMPTY(name)