34 lines
1.1 KiB
C
34 lines
1.1 KiB
C
#ifndef LIST_H
|
|
#define LIST_H
|
|
|
|
void allocthings(void);
|
|
void *allocentry(void);
|
|
void _freeentry(listhead *entry);
|
|
#define freeentry(entry) _freeentry(&(entry->list));
|
|
|
|
void _addtail(listhead *header, listhead *entry);
|
|
#define addtail(head, entry) _addtail(head, &(entry->list));
|
|
|
|
/* remove entry from list */
|
|
void _removeitem(listhead *entry);
|
|
#define removeitem(entry) _removeitem(&(entry->list));
|
|
|
|
/* returns previous entry, deletes entry */
|
|
listhead* delinkhead(listhead *entry);
|
|
#define delink(entry) delinkhead(&(entry->list));
|
|
|
|
|
|
void initheader(listhead *head);
|
|
|
|
/* listhead *head, XXX *item */
|
|
#define foreach_list_fast(head, item) \
|
|
for (item = (void*) (head)->next; (listhead*) item != (head); item = (void*) ((listhead*)item)->next)
|
|
|
|
/* listhead *head, XXX *item, XXX *next : you are allowed to delink(item) */
|
|
#define foreach_list_safe(head, item, next) \
|
|
for (item = (void*) (head)->next, next = (void*) ((listhead*)item)->next; (listhead*) item != (head); item = next, next = (void*) ((listhead*)item)->next)
|
|
|
|
#define list_empty(head) ((head) == (head)->next)
|
|
|
|
#endif
|