X-Git-Url: http://git.meshlink.io/?p=catta;a=blobdiff_plain;f=include%2Fcatta%2Fllist.h;h=59a72742d3219dfa03b72e8c7d0588b80c858be9;hp=a2321b6a551a591bb92264a224359410c71ad720;hb=59e603d00947dfa0ee068c6ec15742fa75c44a27;hpb=fa43d5a814f153ffcfd6296e77f6f0df5c597cf9 diff --git a/include/catta/llist.h b/include/catta/llist.h index a2321b6..59a7274 100644 --- a/include/catta/llist.h +++ b/include/catta/llist.h @@ -55,6 +55,17 @@ CATTA_C_DECL_BEGIN *_head = _item; \ } while (0) +/** Append an item to the list */ +#define CATTA_LLIST_APPEND(t,name,head,item) do { \ + t **_cur = &(head), *_prev, *_item = (item); \ + assert(_item); \ + while ((_prev = *_cur)) \ + _cur = &_prev->name##_next; \ + _item->name##_prev = _prev; \ + _item->name##_next = NULL; \ + *_cur = _item; \ + } while (0) + /** Remove an item from the list */ #define CATTA_LLIST_REMOVE(t,name,head,item) do { \ t **_head = &(head), *_item = (item); \