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;
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;
}