sdlbomber/list.h

27 lines
810 B
C

#ifndef LIST_H
#define LIST_H
void allocthings(void);
void *allocentry(void);
void _addtail(listhead *header, listhead *entry);
#define addtail(head, entry) _addtail(head, &(entry->list));
/* returns previous 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)
#endif