From: Howard Chu Date: Wed, 21 Sep 2005 15:19:36 +0000 (+0000) Subject: Fix tavl_delete threading X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~401 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fcac0626add8495a164b5ed1c187eaad8e881fb3;p=openldap Fix tavl_delete threading --- diff --git a/libraries/liblutil/tavl.c b/libraries/liblutil/tavl.c index 73ab46984d..923356c2ea 100644 --- a/libraries/liblutil/tavl.c +++ b/libraries/liblutil/tavl.c @@ -244,7 +244,10 @@ tavl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) nside = 0; } else { q = NULL; - /* No children, no thread to preserve */ + if ( depth > 0 ) + r = p->avl_link[pdir[depth-1]]; + else + r = NULL; } ber_memfree( p ); @@ -256,8 +259,8 @@ tavl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) /* set the child into p's parent */ depth--; - side = pdir[depth]; p = pptr[depth]; + side = pdir[depth]; p->avl_link[side] = q; /* Update child thread */ @@ -266,16 +269,19 @@ tavl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) q = q->avl_link[nside] ) ; q->avl_link[nside] = r; } else { - /* NULL links are always threads */ p->avl_bits[side] = AVL_THREAD; + p->avl_link[side] = r; } - side_bf = avl_bfs[side]; top = NULL; shorter = 1; - nside = !side; while ( shorter ) { + p = pptr[depth]; + side = pdir[depth]; + nside = !side; + side_bf = avl_bfs[side]; + /* case 1: height unchanged */ if ( p->avl_bf == EH ) { /* Tree is now heavier on opposite side */ @@ -368,9 +374,6 @@ tavl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) if ( !depth ) break; depth--; - p = pptr[depth]; - side = pdir[depth]; - side_bf = avl_bfs[side]; } /* end while(shorter) */ return data;