diff options
Diffstat (limited to 'src/libmowgli/container/list.h')
-rw-r--r-- | src/libmowgli/container/list.h | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/libmowgli/container/list.h b/src/libmowgli/container/list.h index 19905b4..338e51c 100644 --- a/src/libmowgli/container/list.h +++ b/src/libmowgli/container/list.h @@ -25,13 +25,17 @@ #define __MOWGLI_LIST_H__ /* macros for linked lists */ -#define MOWGLI_LIST_FOREACH(n, head) for (n = (head); n; n = n->next) -#define MOWGLI_LIST_FOREACH_NEXT(n, head) for (n = (head); n->next; n = n->next) -#define MOWGLI_LIST_FOREACH_PREV(n, tail) for (n = (tail); n; n = n->prev) +#define MOWGLI_LIST_FOREACH(n, head) \ + for (n = (head); n; n = n->next) +#define MOWGLI_LIST_FOREACH_NEXT(n, head) \ + for (n = (head); n->next; n = n->next) +#define MOWGLI_LIST_FOREACH_PREV(n, tail) \ + for (n = (tail); n; n = n->prev) #define MOWGLI_LIST_LENGTH(list) (list)->count -#define MOWGLI_LIST_FOREACH_SAFE(n, tn, head) for (n = (head), tn = n ? n->next : NULL; n != NULL; n = tn, tn = n ? n->next : NULL) +#define MOWGLI_LIST_FOREACH_SAFE(n, tn, head) \ + for (n = (head), tn = n ? n->next : NULL; n != NULL; n = tn, tn = n ? n->next : NULL) /* list node struct */ typedef struct mowgli_node_ mowgli_node_t; @@ -39,18 +43,18 @@ typedef struct mowgli_list_ mowgli_list_t; struct mowgli_node_ { - struct mowgli_node_ *next, *prev; - void *data; /* pointer to real structure */ + struct mowgli_node_ *next, *prev; + + void *data; /* pointer to real structure */ }; /* node list struct */ struct mowgli_list_ { mowgli_node_t *head, *tail; - size_t count; /* how many entries in the list */ + size_t count; /* how many entries in the list */ }; -extern void mowgli_node_bootstrap(void); extern mowgli_node_t *mowgli_node_create(void); extern void mowgli_node_free(mowgli_node_t *n); extern void mowgli_node_add(void *data, mowgli_node_t *n, mowgli_list_t *l); |