]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Hack to alter the behaviour of fr_rb_replace depending on whether in the fr_node_t...
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 16 Apr 2021 00:30:26 +0000 (19:30 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 16 Apr 2021 00:30:26 +0000 (19:30 -0500)
src/lib/util/rb.c

index 6be2fd4caae61c3bd415cce4ffe9206f5be7709b..9d3b3f176bc7c56a6294b03bcf215b9979438f7e 100644 (file)
@@ -643,7 +643,19 @@ int fr_rb_replace(fr_rb_tree_t *tree, void const *data)
                return ret;
        }
        old_data = node->data;
-       node->data = UNCONST(void *, data);
+
+       /*
+        *      If the fr_node_t is inline with the
+        *      data structure, we need to delete
+        *      the old node out of the tree, and
+        *      perform a normal insert operation.
+        */
+       if (tree->node_alloc == _node_inline_alloc) {
+               delete_internal(tree, node, false);
+               insert_node(tree, UNCONST(void *, data));
+       } else {
+               node->data = UNCONST(void *, data);
+       }
        UNLOCK(tree);
 
        if (tree->data_free) tree->data_free(old_data);