From 40f818daef579281bc63ccf3bfc27162b6199f73 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 25 May 2006 05:03:56 +0000 Subject: [PATCH] Fix tavl_delete for two-node trees --- libraries/liblutil/tavl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/liblutil/tavl.c b/libraries/liblutil/tavl.c index 0e7283c554..0fd2b7992a 100644 --- a/libraries/liblutil/tavl.c +++ b/libraries/liblutil/tavl.c @@ -284,6 +284,13 @@ tavl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) ber_memfree( p ); + /* Update child thread */ + if ( q ) { + for ( ; q->avl_bits[nside] == AVL_CHILD && q->avl_link[nside]; + q = q->avl_link[nside] ) ; + q->avl_link[nside] = r; + } + if ( !depth ) { *root = q; return data; @@ -295,12 +302,7 @@ tavl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) side = pdir[depth]; p->avl_link[side] = q; - /* Update child thread */ - if ( q ) { - for ( ; q->avl_bits[nside] == AVL_CHILD && q->avl_link[nside]; - q = q->avl_link[nside] ) ; - q->avl_link[nside] = r; - } else { + if ( !q ) { p->avl_bits[side] = AVL_THREAD; p->avl_link[side] = r; } -- 2.39.5