Skip to contentSkip to conversation

rbtree: add comment to rb_insert_augmented()

PATCH In review Lai Jiangshan 2 participants 2 messages Sep 17, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rbtree: add comment to rb_insert_augmented()

The comment is copied from Documentation/rbtree.txt, but this comment is so important that it should also be in the code.

CC Andrew Morton <[email protected]>
CC Michel Lespinasse <[email protected]>
---
 include/linux/rbtree_augmented.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
include/linux/rbtree_augmented.h +10 -0
index fea49b5..378c5ee 100644
@@ -43,6 +43,16 @@ struct rb_augment_callbacks {
 
 extern void __rb_insert_augmented(struct rb_node *node, struct rb_root *root,
 	void (*augment_rotate)(struct rb_node *old, struct rb_node *new));
+/*
+ * Fixup the rbtree and update the augmented information when rebalancing.
+ *
+ * On insertion, the user must update the augmented information on the path
+ * leading to the inserted node, then call rb_link_node() as usual and
+ * rb_augment_inserted() instead of the usual rb_insert_color() call.
+ * If rb_augment_inserted() rebalances the rbtree, it will callback into
+ * a user provided function to update the augmented information on the
+ * affected subtrees.
+ */
 static inline void
 rb_insert_augmented(struct rb_node *node, struct rb_root *root,
 		    const struct rb_augment_callbacks *augment)
Signature · 1 line
1.7.4.4
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Lai Jiangshan

The comment is copied from Documentation/rbtree.txt, but this comment is so important that it should also be in the code.

CC Andrew Morton <[email protected]>
CC Michel Lespinasse <[email protected]>

Looks good, thanks for proposing this.

Signature · 2 lines
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.