From: Howard Chu Date: Mon, 26 Sep 2005 08:57:19 +0000 (+0000) Subject: avl_delete... X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~377 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8c3e9ddb1cb2f1f23ef9af3f4cd398f8d284e9f2;p=openldap avl_delete... --- diff --git a/libraries/liblutil/avl.c b/libraries/liblutil/avl.c index e5a5153d08..14b4c46fda 100644 --- a/libraries/liblutil/avl.c +++ b/libraries/liblutil/avl.c @@ -230,14 +230,13 @@ avl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) /* fix stack positions: old parent of p points to q */ pptr[side] = q; if ( side ) { - --side; - r = pptr[side]; - r->avl_link[pdir[side]] = q; + r = pptr[side-1]; + r->avl_link[pdir[side-1]] = q; } else { *root = q; } /* new parent of p points to p */ - if ( depth > 1 ) { + if ( depth-side > 1 ) { r = pptr[depth-1]; r->avl_link[1] = p; } else { @@ -246,7 +245,7 @@ avl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) } /* now

has at most one child, get it */ - q = p->avl_link[0]; + q = p->avl_link[0] ? p->avl_link[0] : p->avl_link[1]; ber_memfree( p ); diff --git a/libraries/liblutil/tavl.c b/libraries/liblutil/tavl.c index 77069393ae..f588c71d88 100644 --- a/libraries/liblutil/tavl.c +++ b/libraries/liblutil/tavl.c @@ -244,14 +244,13 @@ tavl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) /* fix stack positions: old parent of p points to q */ pptr[side] = q; if ( side ) { - --side; - r = pptr[side]; - r->avl_link[pdir[side]] = q; + r = pptr[side-1]; + r->avl_link[pdir[side-1]] = q; } else { *root = q; } /* new parent of p points to p */ - if ( depth > 1 ) { + if ( depth-side > 1 ) { r = pptr[depth-1]; r->avl_link[1] = p; } else {