Changeset 6e93c836 in rtems


Ignore:
Timestamp:
Jul 22, 2014, 5:42:54 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
b767683a
Parents:
4cd55724
git-author:
Sebastian Huber <sebastian.huber@…> (07/22/14 17:42:54)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/29/14 12:05:08)
Message:

rbtree: Simplify off-tree handling

Only use the parent pointer, since this pointer is never NULL for nodes
which are part of a tree.

Rename functions from *_off_rbtree() to *_off_tree().

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/include/rtems/rbtree.h

    r4cd55724 r6e93c836  
    122122 * indicating the @a node is not part of any rbtree.
    123123 */
    124 RTEMS_INLINE_ROUTINE void rtems_rbtree_set_off_rbtree(
     124RTEMS_INLINE_ROUTINE void rtems_rbtree_set_off_tree(
    125125  rtems_rbtree_node *node
    126126)
    127127{
    128   _RBTree_Set_off_rbtree( node );
     128  _RBTree_Set_off_tree( node );
    129129}
    130130
     
    135135 * off rbtree if the next and previous fields are set to NULL.
    136136 */
    137 RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_node_off_rbtree(
     137RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_node_off_tree(
    138138  const rtems_rbtree_node *node
    139139)
    140140{
    141   return _RBTree_Is_node_off_rbtree( node );
     141  return _RBTree_Is_node_off_tree( node );
    142142}
    143143
  • cpukit/score/include/rtems/score/rbtree.h

    r4cd55724 r6e93c836  
    246246 *
    247247 * This function does not set the node off-tree.  In case this is desired, then
    248  * call _RBTree_Set_off_rbtree() after the extraction.
     248 * call _RBTree_Set_off_tree() after the extraction.
    249249 *
    250250 * In case the node to extract is not a node of the tree, then this function
     
    274274
    275275/**
    276  * @brief Set off RBtree.
    277  *
    278  * This function sets the parent and child fields of the @a node to NULL
    279  * indicating the @a node is not part of a rbtree.
    280  *
    281  */
    282 RTEMS_INLINE_ROUTINE void _RBTree_Set_off_rbtree(
    283     RBTree_Node *node
    284     )
    285 {
    286   node->parent = node->child[RBT_LEFT] = node->child[RBT_RIGHT] = NULL;
    287 }
    288 
    289 /**
    290  * @brief Is the node off RBTree.
    291  *
    292  * This function returns true if the @a node is not on a rbtree. A @a node is
    293  * off rbtree if the parent and child fields are set to NULL.
    294  */
    295 RTEMS_INLINE_ROUTINE bool _RBTree_Is_node_off_rbtree(
    296     const RBTree_Node *node
    297     )
    298 {
    299   return (node->parent == NULL) &&
    300          (node->child[RBT_LEFT] == NULL) &&
    301          (node->child[RBT_RIGHT] == NULL);
     276 * @brief Sets a red-black tree node as off-tree.
     277 *
     278 * Do not use this function on nodes which are a part of a tree.
     279 *
     280 * @param[in] the_node The node to set off-tree.
     281 *
     282 * @see _RBTree_Is_node_off_tree().
     283 */
     284RTEMS_INLINE_ROUTINE void _RBTree_Set_off_tree( RBTree_Node *the_node )
     285{
     286  the_node->parent = NULL;
     287}
     288
     289/**
     290 * @brief Returns true, if this red-black tree node is off-tree, and false
     291 * otherwise.
     292 *
     293 * @param[in] the_node The node to test.
     294 *
     295 * @retval true The node is not a part of a tree (off-tree).
     296 * @retval false Otherwise.
     297 *
     298 * @see _RBTree_Set_off_tree().
     299 */
     300RTEMS_INLINE_ROUTINE bool _RBTree_Is_node_off_tree(
     301  const RBTree_Node *the_node
     302)
     303{
     304  return the_node->parent == NULL;
    302305}
    303306
  • testsuites/sptests/sprbtree01/init.c

    r4cd55724 r6e93c836  
    236236  rtems_rbtree_initialize_empty( &rbtree1 );
    237237
    238   rtems_rbtree_set_off_rbtree( &node1.Node );
    239   rtems_test_assert( rtems_rbtree_is_node_off_rbtree( &node1.Node ) );
     238  rtems_rbtree_set_off_tree( &node1.Node );
     239  rtems_test_assert( rtems_rbtree_is_node_off_tree( &node1.Node ) );
    240240
    241241  /* verify that the rbtree insert work */
     
    248248  rb_insert_unique( &rbtree1, &node2.Node );
    249249
    250   rtems_test_assert( !rtems_rbtree_is_node_off_rbtree( &node1.Node ) );
     250  rtems_test_assert( !rtems_rbtree_is_node_off_tree( &node1.Node ) );
    251251
    252252  _RBTree_Rotate(NULL, RBT_LEFT);
     
    361361    rtems_test_exit(0);
    362362  }
    363   rtems_test_assert( !rtems_rbtree_is_node_off_rbtree( p ) );
     363  rtems_test_assert( !rtems_rbtree_is_node_off_tree( p ) );
    364364  rb_insert_unique(&rbtree1, p);
    365365
Note: See TracChangeset for help on using the changeset viewer.