Changeset b767683a in rtems


Ignore:
Timestamp:
Jul 22, 2014, 8:49:09 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
40dcafa
Parents:
6e93c836
git-author:
Sebastian Huber <sebastian.huber@…> (07/22/14 20:49:09)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/29/14 12:05:17)
Message:

rbtree: Rename find header in find control

Simplify _RBTree_Find_control(). Avoid superfluous NULL pointer checks.

Files:
4 edited

Legend:

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

    r6e93c836 rb767683a  
    370370
    371371/**
    372  * @copydoc _RBTree_Find_header()
    373  */
    374 RTEMS_INLINE_ROUTINE rtems_rbtree_control *rtems_rbtree_find_header(
    375   rtems_rbtree_node *the_node
    376 )
    377 {
    378   return _RBTree_Find_header( the_node );
     372 * @copydoc _RBTree_Find_control()
     373 */
     374RTEMS_INLINE_ROUTINE rtems_rbtree_control *rtems_rbtree_find_control(
     375  const rtems_rbtree_node *the_node
     376)
     377{
     378  return _RBTree_Find_control( the_node );
    379379}
    380380
  • cpukit/score/include/rtems/score/rbtree.h

    r6e93c836 rb767683a  
    432432
    433433/**
    434  * @brief Find the RBTree_Control header given a node in the tree.
    435  *
    436  * This function returns a pointer to the header of the Red Black
    437  * Tree containing @a the_node if it exists, and NULL if not.
    438  */
    439 RTEMS_INLINE_ROUTINE RBTree_Control *_RBTree_Find_header(
    440     RBTree_Node *the_node
    441     )
    442 {
    443   if(!the_node) return NULL;
    444   if(!(the_node->parent)) return NULL;
    445   while(the_node->parent) the_node = the_node->parent;
    446   return (RBTree_Control*)the_node;
     434 * @brief Finds the red-black tree control given a node in the tree.
     435 *
     436 * In case the node is not a node of a tree, then this function yields
     437 * unpredictable results.
     438 *
     439 * @param[in] the_node The node of interest.
     440 *
     441 * @return The red-black tree control of the node.
     442 */
     443RTEMS_INLINE_ROUTINE RBTree_Control *_RBTree_Find_control(
     444  const RBTree_Node *the_node
     445)
     446{
     447  RBTree_Node    *parent = the_node->parent;
     448  RBTree_Control *rbtree;
     449
     450  do {
     451    rbtree = (RBTree_Control *) parent;
     452    parent = parent->parent;
     453  } while ( parent != NULL );
     454
     455  return rbtree;
    447456}
    448457
  • testsuites/sptests/sprbtree01/init.c

    r6e93c836 rb767683a  
    581581
    582582  p = rb_find_unique(&rbtree1, &search_node.Node);
    583   puts( "INIT - Verify rtems_rbtree_find_header" );
    584   if (rtems_rbtree_find_header(p) != &rbtree1) {
     583  puts( "INIT - Verify rtems_rbtree_find_control" );
     584  if (rtems_rbtree_find_control(p) != &rbtree1) {
    585585    puts ("INIT - ERROR ON RBTREE HEADER MISMATCH");
    586586    rtems_test_exit(0);
     
    621621  }
    622622
    623   if (rtems_rbtree_find_header(NULL) != NULL) {
    624     puts ("INIT - ERROR ON RBTREE HEADER MISMATCH");
    625     rtems_test_exit(0);
    626   }
    627 
    628623  puts("INIT - Insert 20 random numbers");
    629624  for (i = 0; i < 20; i++) {
  • testsuites/sptests/sprbtree01/sprbtree01.scn

    r6e93c836 rb767683a  
    1919INIT - Verify rtems_rbtree_find
    2020INIT - Verify rtems_rbtree_predecessor/successor
    21 INIT - Verify rtems_rbtree_find_header
     21INIT - Verify rtems_rbtree_find_control
    2222INIT - Removing 100 nodes
    2323INIT - Insert 20 random numbers
Note: See TracChangeset for help on using the changeset viewer.