7 #define LLIST_ALLOC_SIZE 4096
14 llist_pool
llist_create (void)
16 llist_pool result
= (llist_pool
) xmalloc (sizeof (struct _llist_pool
));
18 result
->allocated
= NULL
;
22 void llist_destroy (llist_pool pool
)
25 for (el
= pool
->allocated
; el
; el
= ne
) {
30 pool
->allocated
= NULL
;
35 llist
llist_alloc (llist_pool pool
)
40 l
= (llist
) xmalloc (LLIST_ALLOC_SIZE
* sizeof (struct _llist
));
41 l
->next
= pool
->allocated
;
43 for (i
= 1; i
< LLIST_ALLOC_SIZE
- 1; i
++) {
44 l
[i
].next
= &l
[i
+ 1];
54 llist
llist_add (llist_pool pool
, llist l
, void *val
)
56 llist el
= llist_alloc (pool
);
62 void llist_free (llist_pool pool
, llist el
)
64 el
->next
= pool
->free
;
68 void llist_freeall (llist_pool pool
, llist l
)