summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/rbtreenext.c
diff options
context:
space:
mode:
authorGedare Bloom <gedare@rtems.org>2012-05-03 12:43:29 -0400
committerGedare Bloom <gedare@rtems.org>2012-05-08 18:40:44 -0400
commitf53aa8d3026eb97e3c67e44a1c931442dbc95010 (patch)
tree070391bda95c04c9a8b5d4e9489f4c0788c0e05f /cpukit/score/src/rbtreenext.c
parentPR2061: RBTree: updating min and max on insert with duplicates (diff)
downloadrtems-f53aa8d3026eb97e3c67e44a1c931442dbc95010.tar.bz2
rbtree: API changes. Remove rbtree control node from RBTree_Next.
The implementation of RBTree_Next was using an awkward construction to detect and avoid accessing the false root of the red-black tree. To deal with the false root, RBTree_Next was comparing node parents with the control node. Instead the false root can be detected by checking if the grandparent of a node exists; the grandparent of the tree's true root is NULL by definition so the root of the tree is found while walking up the tree by checking for the non-existence of a grandparent. This change propagates into the predecessor/successor and iterate functions.
Diffstat (limited to 'cpukit/score/src/rbtreenext.c')
-rw-r--r--cpukit/score/src/rbtreenext.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/cpukit/score/src/rbtreenext.c b/cpukit/score/src/rbtreenext.c
index e79f175f35..0aee0434f6 100644
--- a/cpukit/score/src/rbtreenext.c
+++ b/cpukit/score/src/rbtreenext.c
@@ -28,7 +28,6 @@
#include <rtems/score/isr.h>
RBTree_Node *_RBTree_Next_unprotected(
- const RBTree_Control *rbtree,
const RBTree_Node *node,
RBTree_Direction dir
)
@@ -43,18 +42,17 @@ RBTree_Node *_RBTree_Next_unprotected(
next = current;
}
} else {
- const RBTree_Node *null = (const RBTree_Node *) rbtree;
RBTree_Node *parent = node->parent;
- if ( parent != null && node == parent->child [opp_dir] ) {
+ if ( parent->parent && node == parent->child [opp_dir] ) {
next = parent;
} else {
- while ( parent != null && node == parent->child [dir] ) {
+ while ( parent->parent && node == parent->child [dir] ) {
node = parent;
- parent = node->parent;
+ parent = parent->parent;
}
- if ( parent != null ) {
+ if ( parent->parent ) {
next = parent;
}
}
@@ -64,7 +62,6 @@ RBTree_Node *_RBTree_Next_unprotected(
}
RBTree_Node *_RBTree_Next(
- const RBTree_Control *rbtree,
const RBTree_Node *node,
RBTree_Direction dir
)
@@ -73,7 +70,7 @@ RBTree_Node *_RBTree_Next(
ISR_Level level;
_ISR_Disable( level );
- next = _RBTree_Next_unprotected( rbtree, node, dir );
+ next = _RBTree_Next_unprotected( node, dir );
_ISR_Enable( level );
return next;