*
* @param[in] node to check.
* @return
- * - True if node is in the tree.
- * - False if node is not in the tree.
+ * - true if node is in the tree.
+ * - talse if node is not in the tree.
*/
static inline bool fr_rb_node_inline_in_tree(fr_rb_node_t *node)
{
return ((!node->left && !node->right && !node->parent) || (node->being_freed));
}
+/** Check to see if nodes are equivalent and if they are, replace one with the other
+ *
+ * @param[in] tree Used to access the comparitor.
+ * @param[in] to_replace Node to replace in the tree.
+ * @param[in] replacement Replacement.
+ * @return
+ * - true on success.
+ * - false if nodes were not equivalent.
+ */
+static inline bool fr_rb_node_inline_replace(fr_rb_tree_t *tree, fr_rb_node_t *to_replace, fr_rb_node_t *replacement)
+{
+ if (tree->data_cmp(to_replace->data, replacement->data) != 0) return false;
+
+ memcpy(replacement, to_replace, sizeof(*replacement));
+ memset(to_replace, 0, sizeof(*to_replace));
+
+ return true;
+}
+
/** Iterator structure for in-order traversal of an rbtree
*/
typedef struct {