X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftlist%2Ftlist.h;h=3576146c04f1a82488d2f4f707d1ca7b6b06798d;hp=9f62869b2b19c23c3fcb812ed2a6420a45a847a7;hb=6a906358d922800c7358c5c46c34bf4a5e6863ad;hpb=be2b527792d574ef8cf506d1a168d92354e23cc5 diff --git a/ccan/tlist/tlist.h b/ccan/tlist/tlist.h index 9f62869b..3576146c 100644 --- a/ccan/tlist/tlist.h +++ b/ccan/tlist/tlist.h @@ -221,6 +221,22 @@ #define tlist_for_each(h, i, member) \ list_for_each(tlist_raw((h), (i)), (i), member) +/** + * tlist_for_each - iterate through a list backwards. + * @h: the tlist + * @i: an iterator of suitable type for this list. + * @member: the list_node member of @i + * + * This is a convenient wrapper to iterate @i over the entire list. It's + * a for loop, so you can break and continue as normal. + * + * Example: + * tlist_for_each_rev(&parent->children, child, list) + * printf("Name: %s\n", child->name); + */ +#define tlist_for_each_rev(h, i, member) \ + list_for_each_rev(tlist_raw((h), (i)), (i), member) + /** * tlist_for_each_safe - iterate through a list, maybe during deletion * @h: the tlist