- {
- /* Copy everything except data from _src to _dst, relink.
- * This is a bit of a messy addon, since the algorithm is originally
- * based around moving the actual data(key) around, but we have the
- * requirement that data can't move, so everything is done normally but
- * the pointers are just swapped afterwards.
- */
-
- aatree_node *pdst = aatree_get_node( tree, _ptrswap_dst ),
- *psrc = aatree_get_node( tree, _ptrswap_src );
-
- pdst->count = psrc->count;
- pdst->level = psrc->level;
- pdst->left = psrc->left;
- pdst->right = psrc->right;
- pdst->parent = psrc->parent;
-
- if( pdst->parent != AATREE_PTR_NIL )
- {
- aatree_node *parent = aatree_get_node( tree, pdst->parent );
-
- if( parent->left == _ptrswap_src )
- parent->left = _ptrswap_dst;
- else if( parent->right == _ptrswap_src )
- parent->right = _ptrswap_dst;
- }
- else
- {
- root = _ptrswap_dst;
- }
-
- if( pdst->left != AATREE_PTR_NIL )
- aatree_get_node( tree, pdst->left )->parent = _ptrswap_dst;
- if( pdst->right != AATREE_PTR_NIL )
- aatree_get_node( tree, pdst->right )->parent = _ptrswap_dst;
- }