forgotten commit. disabled until egl is adapted.
[AROS-Contrib.git] / MultiMedia / cdxlplay / include / lists.h
blob14f82e30bd8a9d3a04fc4473f983ba68c1e19403
1 /*
2 ** CDXLPlay (C) 2009 Fredrik Wikstrom
3 **/
5 #ifndef LISTS_H
6 #define LISTS_H
8 #include <stdint.h>
10 struct node {
11 struct node *succ;
12 struct node *pred;
15 struct list {
16 struct node *head;
17 struct node *tail;
18 struct node *tailpred;
21 static inline void init_list(struct list *list) {
22 list->head = (struct node *)&list->tail;
23 list->tail = NULL;
24 list->tailpred = (struct node *)&list->head;
27 static inline int list_is_empty(struct list *list) {
28 return (list->head == (struct node *)&list->tail);
31 static inline void add_head(struct list *list, struct node *node) {
32 node->succ = list->head;
33 node->pred = (struct node *)&list->head;
34 node->succ->pred = node;
35 node->pred->succ = node;
38 static inline void add_tail(struct list *list, struct node *node) {
39 node->succ = (struct node *)&list->tail;
40 node->pred = list->tailpred;
41 node->succ->pred = node;
42 node->pred->succ = node;
45 static inline struct node *rem_node(struct node *node) {
46 if (node && node->succ && node->pred) {
47 node->succ->pred = node->pred;
48 node->pred->succ = node->succ;
49 node->succ = NULL;
50 node->pred = NULL;
51 return node;
53 return NULL;
56 static inline struct node *rem_head(struct list *list) {
57 return rem_node(list->head);
60 static inline struct node *rem_tail(struct list *list) {
61 return rem_node(list->tail);
64 #endif