Fix end conditions for tavl_end and tavl_next

This commit is contained in:
Howard Chu 2005-09-23 06:25:13 +00:00
parent a51cf20cea
commit e840a34fef

View File

@ -475,7 +475,7 @@ Avlnode *
tavl_end( Avlnode *root, int dir )
{
if ( root ) {
while ( root->avl_bits[dir] == AVL_CHILD )
while ( root->avl_bits[dir] == AVL_CHILD && root->avl_link[dir] )
root = root->avl_link[dir];
}
return root;
@ -491,7 +491,7 @@ tavl_next( Avlnode *root, int dir )
root = root->avl_link[dir];
if ( c == AVL_CHILD ) {
dir ^= 1;
while ( root->avl_bits[dir] == AVL_CHILD )
while ( root && root->avl_bits[dir] == AVL_CHILD )
root = root->avl_link[dir];
}
}