]> git.sur5r.net Git - openldap/commitdiff
Fix tavl_delete for two-node trees
authorHoward Chu <hyc@openldap.org>
Thu, 25 May 2006 05:03:56 +0000 (05:03 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 25 May 2006 05:03:56 +0000 (05:03 +0000)
libraries/liblutil/tavl.c

index 0e7283c55422f13d392616356dee1f7295e67583..0fd2b7992adeee784e46ae9199880d68a62f0edb 100644 (file)
@@ -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;
        }