sdlbomber/list.h

34 lines
1.1 KiB
C
Raw Normal View History

#ifndef LIST_H
#define LIST_H
void allocthings(void);
void *allocentry(void);
2009-08-11 17:09:59 +00:00
void _freeentry(listhead *entry);
#define freeentry(entry) _freeentry(&(entry->list));
2009-08-11 15:19:43 +00:00
void _addtail(listhead *header, listhead *entry);
#define addtail(head, entry) _addtail(head, &(entry->list));
2009-08-11 17:09:59 +00:00
/* remove entry from list */
void _removeitem(listhead *entry);
#define removeitem(entry) _removeitem(&(entry->list));
/* returns previous entry, deletes entry */
2009-08-11 15:19:43 +00:00
listhead* delinkhead(listhead *entry);
#define delink(entry) delinkhead(&(entry->list));
void initheader(listhead *head);
2009-08-11 15:46:32 +00:00
/* 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)
2009-08-11 17:09:59 +00:00
#define list_empty(head) ((head) == (head)->next)
#endif