void destroyIonDb(char *iondbName) { Sdr sdr = getIonsdr(); IonDB iondbBuf; Object iondbObj; iondbObj = sdr_find(sdr, iondbName, NULL); if (iondbObj == NULL) return; sdr_read(sdr, (char *) &iondbBuf, iondbObj, sizeof(IonDB)); sdr_list_destroy(sdr, iondbBuf.contacts, NULL, NULL); sdr_list_destroy(sdr, iondbBuf.ranges, NULL, NULL); sdr_free(sdr, iondbObj); //fprintf(stderr, "ionDb destroyed: %d\n", getOwnNodeNbr()); }
int dtn2_removePlan(char *nodeNm) { Sdr sdr = getIonsdr(); char nodeName[SDRSTRING_BUFSZ]; Object elt; Object planObj; OBJ_POINTER(Dtn2Plan, plan); CHKERR(nodeNm); if (filterNodeName(nodeName, nodeNm) < 0) { return 0; } CHKERR(sdr_begin_xn(sdr)); elt = locatePlan(nodeName, NULL); if (elt == 0) { sdr_exit_xn(sdr); writeMemoNote("[?] Unknown plan", nodeNm); return 0; } planObj = sdr_list_data(sdr, elt); GET_OBJ_POINTER(sdr, Dtn2Plan, plan, planObj); if (sdr_list_length(sdr, plan->rules) > 0) { sdr_exit_xn(sdr); writeMemoNote("[?] Can't remove plan; still has rules", nodeNm); return 0; } /* Okay to remove this plan from the database. */ sdr_list_delete(sdr, elt, NULL, NULL); dtn2_destroyDirective(&(plan->defaultDirective)); sdr_list_destroy(sdr, plan->rules, NULL, NULL); sdr_free(sdr, plan->nodeName); sdr_free(sdr, planObj); if (sdr_end_xn(sdr) < 0) { putErrmsg("Can't remove plan.", nodeNm); return -1; } return 1; }
static void releaseSdrAcsSignal(Object signalLElt) { Sdr bpSdr = getIonsdr(); Sdr acsSdr = getAcssdr(); Object signalAddr; SdrAcsSignal signal; SdrAcsPendingCust pendingCust; assert(signalLElt != 0); ASSERT_ACSSDR_XN; ASSERT_BPSDR_XN; if (acsSdr == NULL) { putErrmsg("Can't release ACS, SDR not available.", NULL); return; } signalAddr = sdr_list_data(acsSdr, signalLElt); if (signalAddr == 0) { ACSLOG_ERROR("Can't derefence ACS signal to release it."); return; } sdr_peek(acsSdr, signal, signalAddr); sdr_peek(acsSdr, pendingCust, signal.pendingCustAddr); /* Destroy the objects this AcsSignal contains */ sdr_list_destroy(acsSdr, signal.acsFills, releaseSdrAcsFill, NULL); if(signal.acsDue != 0) { destroyBpTimelineEvent(signal.acsDue); } if(signal.serializedZco != 0) { zco_destroy(bpSdr, signal.serializedZco); } /* Destroy this AcsSignal */ sdr_free(acsSdr, signalAddr); sdr_list_delete(acsSdr, signalLElt, NULL, NULL); }