trbt_delete32() was broken and caused SEGV as soon as you tried to
delete an object from a tree.
Rework trbt_delete32() to instead just call talloc_free() instread of trying
to call delete_node() directly.
This makes the "from_destructor" argument to delete_node() redundant
so that parameter is removed too.
Signed-off-by: Ronnie Sahlberg <sahlberg@lenovo-laptop.(none)>
-delete_node(trbt_node_t *node, int from_destructor)
+delete_node(trbt_node_t *node)
{
trbt_node_t *parent, *child, dc;
trbt_node_t *temp = NULL;
{
trbt_node_t *parent, *child, dc;
trbt_node_t *temp = NULL;
/* then delete the temp node.
this node is guaranteed to have at least one leaf
child */
/* then delete the temp node.
this node is guaranteed to have at least one leaf
child */
- delete_node(temp, from_destructor);
- if (!from_destructor) {
- talloc_free(node);
- }
-
/* if we came from a destructor and temp!=NULL this means we
did the node-swap but now the tree still contains the old
node which was freed in the destructor. Not good.
*/
/* if we came from a destructor and temp!=NULL this means we
did the node-swap but now the tree still contains the old
node which was freed in the destructor. Not good.
*/
- if (from_destructor && temp) {
temp->key32 = node->key32;
temp->rb_color = node->rb_color;
temp->key32 = node->key32;
temp->rb_color = node->rb_color;
*/
static int node_destructor(trbt_node_t *node)
{
*/
static int node_destructor(trbt_node_t *node)
{
while(node){
if(key==node->key32){
while(node){
if(key==node->key32){
return;
}
if(key<node->key32){
return;
}
if(key<node->key32){