X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=mware%2Flist.h;h=e28abb43da95097c2e1bcfe03a3bf0021c6da908;hb=0f018838e0d5130255728bbf3aa69e44e4954239;hp=aaa2ad7c7053612ee9e93df32b146c0881826fbb;hpb=00e009957d70dab15575ab310ed83f0b78cc8656;p=bertos.git diff --git a/mware/list.h b/mware/list.h index aaa2ad7c..e28abb43 100755 --- a/mware/list.h +++ b/mware/list.h @@ -15,6 +15,12 @@ /*#* *#* $Log$ + *#* Revision 1.12 2005/01/22 04:21:32 bernie + *#* Add integrity checks. + *#* + *#* Revision 1.11 2004/12/31 16:44:11 bernie + *#* list_remHead(), list_remTail(): Name like normal functions. + *#* *#* Revision 1.10 2004/11/28 23:21:05 bernie *#* Remove obsolete INITLIST macro. *#* @@ -115,6 +121,26 @@ typedef struct _List (l)->tail = (Node *)(&(l)->head); \ } while (0) +/* Make sure that a list is valid (it was initialized and is not corrupted) */ +#ifdef _DEBUG + #define LIST_ASSERT_VALID(l) \ + do { \ + Node *n, *pred; \ + ASSERT((l)->head != NULL); \ + ASSERT((l)->null == NULL); \ + ASSERT((l)->tail != NULL); \ + pred = (Node *)(&(l)->head); \ + FOREACHNODE(n, l) \ + { \ + ASSERT(n->pred == pred); \ + pred = n; \ + } \ + ASSERT(n == (Node *)(&(l)->null)); \ + } while (0) +#else + #define LIST_ASSERT_VALID(l) do {} while (0) +#endif + /*! Add node to list head. */ #define ADDHEAD(l,n) \ do { \ @@ -167,7 +193,7 @@ typedef struct _List * * \return Pointer to node, or NULL if the list was empty. */ -INLINE Node *REMHEAD(List *l) +INLINE Node *list_remHead(List *l) { Node *n; @@ -185,7 +211,7 @@ INLINE Node *REMHEAD(List *l) * * \return Pointer to node, or NULL if the list was empty. */ -INLINE Node *REMTAIL(List *l) +INLINE Node *list_remTail(List *l) { Node *n; @@ -198,4 +224,8 @@ INLINE Node *REMTAIL(List *l) return n; } +/* OBSOLETE names */ +#define REMHEAD list_remHead +#define REMTAIL list_remTail + #endif /* MWARE_LIST_H */