void mds_apf_destroy_entity(struct mds_apf* m, mds_id e) { struct mds_tag* t; for (t = m->tags.first; t; t = t->next) if (mds_has_tag(t,e)) mds_take_tag(t,e); mds_set_copies(&m->remotes, &m->mds, e, NULL); mds_set_copies(&m->ghosts, &m->mds, e, NULL); //seol mds_set_copies(&m->matches, &m->mds, e, NULL); mds_destroy_entity(&(m->mds),e); }
void mds_add_copy(struct mds_net* net, struct mds* m, mds_id e, struct mds_copy c) { struct mds_copies* cs; int t; int p; mds_id i; t = mds_type(e); i = mds_index(e); cs = mds_get_copies(net, e); if (cs) { p = find_place(cs, c.p); cs = realloc(cs, sizeof(struct mds_copies) + (cs->n) * sizeof(struct mds_copy)); /* insert sorted by moving greater items up by one */ memmove(&cs->c[p + 1], &cs->c[p], (cs->n - p) * sizeof(struct mds_copy)); cs->c[p] = c; ++cs->n; net->data[t][i] = cs; } else { cs = mds_make_copies(1); cs->c[0] = c; mds_set_copies(net, m, e, cs); } }