Commit 848ddf97 authored by Pekka Pessi's avatar Pekka Pessi

rbtree.h: rbtree_insert() now returns -1 upon an error.

darcs-hash:20060517182526-65a35-a76e91bda4c307c50f2c3ec570ebdeec9e40a18d.gz
parent 25d29687
......@@ -250,6 +250,15 @@ void prefix##_balance_delete(Type **top, Type *node) \
} \
extern int const prefix##_dummy
/**@fn int rbtree_insert(Type * tree, Type *node, Type **return_old)
*
* Insert a @a node into @a tree.
*
*
* @retval 0 if node was inserted
* @retval -1 if there already was an matching node and return_old is NULL.
*/
/* Insert node into tree. */
#define RBTREE_INSERT(SCOPE, prefix, Type, left, right, parent, \
IS_RED, SET_RED, IS_BLACK, SET_BLACK, COPY_COLOR, \
......@@ -276,6 +285,8 @@ int prefix ## _insert(Type **const tree, \
if (old == node) \
old = NULL; \
else if (old) { \
if (!return_old) return -1; \
\
if ((left(node) = left(old))) \
parent(left(node)) = node; \
if ((right(node) = right(old))) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment