Skip to contentSkip to conversation

Fix the example typo

PATCH Applied Hsin Chang Yu 1 participant 1 message Jun 28, 2024 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix the example typo

Replace the "Sr" with "sr", the example is wrong if sl and N don't have child nodes, so sr should be red node.

---
 lib/rbtree.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/rbtree.c +4 -4
index 5114eda63..989c2d615 100644
@@ -297,9 +297,9 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root,
 				 *   / \           / \
 				 *  N   S    -->  N   sl
 				 *     / \             \
-				 *    sl  Sr            S
+				 *    sl  sr            S
 				 *                       \
-				 *                        Sr
+				 *                        sr
 				 *
 				 * Note: p might be red, and then both
 				 * p and sl are red after rotation(which
@@ -312,9 +312,9 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root,
 				 *   / \            /  \
 				 *  N   sl   -->   P    S
 				 *       \        /      \
-				 *        S      N        Sr
+				 *        S      N        sr
 				 *         \
-				 *          Sr
+				 *          sr
 				 */
 				tmp1 = tmp2->rb_right;
 				WRITE_ONCE(sibling->rb_left, tmp1);
Signature · 1 line
2.34.1