score: Improve red-black tree debug support

Ensure that we extract a node only from the right tree.
This commit is contained in:
Sebastian Huber
2016-08-24 15:25:33 +02:00
parent 83b0229071
commit da15db787b
4 changed files with 19 additions and 3 deletions

View File

@@ -22,6 +22,9 @@ struct rb_node {
struct rb_node *rb_right;
struct rb_node *rb_parent;
int rb_color;
#if defined(RTEMS_DEBUG)
const RBTree_Control *rb_tree;
#endif
};
RTEMS_STATIC_ASSERT(

View File

@@ -39,6 +39,8 @@ extern "C" {
*/
/**@{*/
struct RBTree_Control;
/**
* @brief Red-black tree node.
*
@@ -47,6 +49,9 @@ extern "C" {
*/
typedef struct RBTree_Node {
RB_ENTRY(RBTree_Node) Node;
#if defined(RTEMS_DEBUG)
const struct RBTree_Control *tree;
#endif
} RBTree_Node;
/**
@@ -124,6 +129,7 @@ RTEMS_INLINE_ROUTINE void _RBTree_Initialize_node( RBTree_Node *the_node )
{
#if defined(RTEMS_DEBUG)
_RBTree_Set_off_tree( the_node );
the_node->tree = NULL;
#endif
}
@@ -400,6 +406,10 @@ RTEMS_INLINE_ROUTINE void _RBTree_Initialize_one(
)
{
_Assert( _RBTree_Is_node_off_tree( the_node ) );
#if defined(RTEMS_DEBUG)
_Assert( the_node->tree == NULL );
the_node->tree = the_rbtree;
#endif
RB_ROOT( the_rbtree ) = the_node;
RB_PARENT( the_node, Node ) = NULL;
RB_LEFT( the_node, Node ) = NULL;

View File

@@ -21,8 +21,7 @@ void _RBTree_Extract(
RBTree_Node *the_node
)
{
_Assert( the_node->tree == the_rbtree );
RB_REMOVE( RBTree_Control, the_rbtree, the_node );
#if defined(RTEMS_DEBUG)
_RBTree_Set_off_tree( the_node );
#endif
_RBTree_Initialize_node( the_node );
}

View File

@@ -19,5 +19,9 @@ void _RBTree_Insert_color(
RBTree_Node *the_node
)
{
#if defined(RTEMS_DEBUG)
_Assert( the_node->tree == NULL );
the_node->tree = the_rbtree;
#endif
RBTree_Control_RB_INSERT_COLOR( the_rbtree, the_node );
}