vserver 1.9.3
[linux-2.6.git] / lib / rbtree.c
index 860115d..14b791a 100644 (file)
@@ -235,7 +235,7 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
                struct rb_node *old = node, *left;
 
                node = node->rb_right;
-               while ((left = node->rb_left))
+               while ((left = node->rb_left) != NULL)
                        node = left;
                child = node->rb_right;
                parent = node->rb_parent;
@@ -305,13 +305,26 @@ struct rb_node *rb_first(struct rb_root *root)
 
        n = root->rb_node;
        if (!n)
-               return 0;
+               return NULL;
        while (n->rb_left)
                n = n->rb_left;
        return n;
 }
 EXPORT_SYMBOL(rb_first);
 
+struct rb_node *rb_last(struct rb_root *root)
+{
+       struct rb_node  *n;
+
+       n = root->rb_node;
+       if (!n)
+               return NULL;
+       while (n->rb_right)
+               n = n->rb_right;
+       return n;
+}
+EXPORT_SYMBOL(rb_last);
+
 struct rb_node *rb_next(struct rb_node *node)
 {
        /* If we have a right-hand child, go down and then left as far