summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/rbtreeinsert.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-08-21 20:07:11 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-08-21 20:07:11 +0000
commit74f1c73e969fe7a7b1ca53bb6fcb1336f4a179cb (patch)
tree4f2b74ad7cf7f1c661bdfd0cd89c284964ad2f64 /cpukit/score/src/rbtreeinsert.c
parent2011-08-21 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff)
downloadrtems-74f1c73e969fe7a7b1ca53bb6fcb1336f4a179cb.tar.bz2
2011-08-21 Petr Benes <benesp16@fel.cvut.cz>
PR 1886/cpukit * sapi/include/rtems/rbtree.h, sapi/inline/rtems/rbtree.inl, score/include/rtems/score/rbtree.h, score/inline/rtems/score/rbtree.inl, score/src/rbtree.c, score/src/rbtreeinsert.c: This patch enables inserting duplicate keys into rbtree. It is possible to turn on this feature when initializing the tree.
Diffstat (limited to 'cpukit/score/src/rbtreeinsert.c')
-rw-r--r--cpukit/score/src/rbtreeinsert.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/cpukit/score/src/rbtreeinsert.c b/cpukit/score/src/rbtreeinsert.c
index bb1915de54..1208a3c81a 100644
--- a/cpukit/score/src/rbtreeinsert.c
+++ b/cpukit/score/src/rbtreeinsert.c
@@ -72,7 +72,7 @@ void _RBTree_Validate_insert_unprotected(
* @retval 0 Successfully inserted.
* @retval -1 NULL @a the_node.
* @retval RBTree_Node* if one with equal key to the key of @a the_node exists
- * in @a the_rbtree.
+ * in an unique @a the_rbtree.
*
* @note It does NOT disable interrupts to ensure the atomicity
* of the extract operation.
@@ -97,7 +97,8 @@ RBTree_Node *_RBTree_Insert_unprotected(
/* typical binary search tree insert, descend tree to leaf and insert */
while (iter_node) {
compare_result = the_rbtree->compare_function(the_node, iter_node);
- if ( !compare_result ) return iter_node;
+ if ( the_rbtree->is_unique && !compare_result )
+ return iter_node;
RBTree_Direction dir = (compare_result != -1);
if (!iter_node->child[dir]) {
the_node->child[RBT_LEFT] = the_node->child[RBT_RIGHT] = NULL;
@@ -138,7 +139,7 @@ RBTree_Node *_RBTree_Insert_unprotected(
* only case
*/
-void _RBTree_Insert(
+RBTree_Node *_RBTree_Insert(
RBTree_Control *tree,
RBTree_Node *node
)
@@ -146,6 +147,6 @@ void _RBTree_Insert(
ISR_Level level;
_ISR_Disable( level );
- _RBTree_Insert_unprotected( tree, node );
+ return _RBTree_Insert_unprotected( tree, node );
_ISR_Enable( level );
}