void link_free(link_t link) { if(!link) return; LOG("dropping link %s",link->id->hashname); xht_set(link->mesh->index,link->id->hashname,NULL); // TODO go through ->pipes // TODO go through link->channels xht_free(link->channels); xht_free(link->index); hashname_free(link->id); if(link->x) { xht_set(link->mesh->index,link->token,NULL); e3x_exchange_free(link->x); } free(link); }
void link_free(link_t link) { if(!link) return; LOG("dropping link %s",hashname_short(link->id)); mesh_t mesh = link->mesh; if(mesh->links == link) { mesh->links = link->next; }else{ link_t li; for(li = mesh->links;li;li = li->next) if(li->next == link) { li->next = link->next; } } // drop if(link->x) { e3x_exchange_free(link->x); link->x = NULL; } // notify pipe w/ NULL packet if(link->send_cb) link->send_cb(link, NULL, link->send_arg); // go through link->chans chan_t c, cnext; for(c = link->chans;c;c = cnext) { cnext = chan_next(c); chan_free(c); } hashname_free(link->id); lob_free(link->key); lob_free(link->handshake); free(link); }