lkml.org 
[lkml]   [2013]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/5] rbtree: add rbtree_postorder_for_each_entry_safe() helper
On Fri, Jul 26, 2013 at 02:13:40PM -0700, Cody P Schafer wrote:
> Because deletion (of the entire tree) is a relatively common use of the
> rbtree_postorder iteration, and because doing it safely means fiddling
> with temporary storage, provide a helper to simplify postorder rbtree
> iteration.
>
> Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
> ---
> include/linux/rbtree.h | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
> index 2879e96..64ab98b 100644
> --- a/include/linux/rbtree.h
> +++ b/include/linux/rbtree.h
> @@ -85,4 +85,21 @@ static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
> *rb_link = node;
> }
>
> +/**
> + * rbtree_postorder_for_each_entry_safe - iterate over rb_root in post order of
> + * given type safe against removal of rb_node entry
> + *
> + * @pos: the 'type *' to use as a loop cursor.
> + * @n: another 'type *' to use as temporary storage
> + * @root: 'rb_root *' of the rbtree.
> + * @field: the name of the rb_node field within 'type'.
> + */
> +#define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \
> + for (pos = rb_entry(rb_first_postorder(root), typeof(*pos), field),\
> + n = rb_entry(rb_next_postorder(&pos->field), \
> + typeof(*pos), field); \
> + &pos->field; \
> + pos = n, \
> + n = rb_entry(rb_next_postorder(&pos->field), typeof(*pos), field))

One too many spaces. Also mix of tabs and spaces is weird, but
checkpatch doesn't complain so...

Seth

> +
> #endif /* _LINUX_RBTREE_H */
> --
> 1.8.3.4
>



\
 
 \ /
  Last update: 2013-07-30 18:01    [W:0.075 / U:1.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site