void listcpy(L d, L s, I i) { s->r--; if (s->l) { d->l += s->l; if (s->r && s->t&COMP_t) { // Increase reference count of source's children I ss=t_sizeof(s->t); DO(j,s->l) (**(I**)(LIST_PTR_ATS(s,j,ss)))++; } if (PURE(d->t)==PURE(s->t)) listcpy1(d,s,i); else { DO(j,s->l) LIST_AT(d,i+j) = cpy1(list_at(s,j)); } } if (!s->r) { FREEL(s); } }
Tree * deleteT(site i, Tree *t) { /* Deletes i from the tree if it's there. */ /* Return a pointer to the resulting tree. */ Tree * x; int tsize; if (!t) return NULL; tsize = t->size; t = splay(i,t); if (compare(i, t->key) == 0) { /* found it */ if (!t->left) { x = t->right; } else { x = splay(i, t->left); x->right = t->right; } FREEL(Tree,t); if (x) x->size = tsize-1; return x; } else { return t; /* It wasn't there */ } }