isc_result_t omapi_protocol_destroy (omapi_object_t *h, const char *file, int line) { omapi_protocol_object_t *p; if (h -> type != omapi_type_protocol) return ISC_R_INVALIDARG; p = (omapi_protocol_object_t *)h; if (p -> message) omapi_message_dereference (&p -> message, file, line); /* This will happen if: 1) A default authenticator is supplied to omapi_protocol_connect(), and 2) something goes wrong before the authenticator can be opened. */ if (p -> default_auth && !p -> remote_auth_list) dfree (p -> default_auth, file, line); while (p -> remote_auth_list) { omapi_remote_auth_t *r = p -> remote_auth_list -> next; p -> remote_auth_list = r; if (r) { omapi_object_dereference (&r -> a, file, line); dfree (r, file, line); } } return ISC_R_SUCCESS; }
void trace_free_all () { trace_type_t *tp; int i; tp = new_trace_types; while (tp) { new_trace_types = tp -> next; if (tp -> name) { dfree (tp -> name, MDL); tp -> name = (char *)0; } dfree (tp, MDL); tp = new_trace_types; } for (i = 0; i < trace_type_count; i++) { if (trace_types [i]) { if (trace_types [i] -> name) dfree (trace_types [i] -> name, MDL); dfree (trace_types [i], MDL); } } dfree (trace_types, MDL); trace_types = (trace_type_t **)0; trace_type_count = trace_type_max = 0; omapi_array_free (&trace_listeners, MDL); omapi_array_free (&omapi_connections, MDL); }
void dtfree(datrie *pvdt) { datrie_t *pdt = (datrie_t *)pvdt; if (pdt->pwarry_) { dfree(pdt->pwarry_); pdt->pwarry_ = NULL; } if (pdt->pextra_) { dfree(pdt->pextra_); pdt->pextra_ = NULL; } if (pdt->peidxs_) { dfree(pdt->peidxs_); pdt->peidxs_ = NULL; } if (pdt->code_maps_) { free(pdt->code_maps_); pdt->code_maps_ = NULL; } if (pdt->ord_tree_) { dfree(pdt->ord_tree_); pdt->ord_tree_ = NULL; } if (pdt->da_trie_) { free(pdt->da_trie_); pdt->da_trie_ = NULL; } free(pdt); }
void spr_Destroy(Sprite *pSprite) { uint32 i; if(pSprite->m_pFileIdent) { pSprite->m_pFileIdent->m_pData = LTNULL; } // Remove ourselves from the m_Sprites lists dl_Remove(&pSprite->m_Link); dl_TieOff(&pSprite->m_Link); if(pSprite->m_Anims) { for(i=0; i < pSprite->m_nAnims; i++) { if(pSprite->m_Anims[i].m_Frames) { dfree(pSprite->m_Anims[i].m_Frames); } } dfree(pSprite->m_Anims); } dfree(pSprite); }
kucode_t button_destroy( gui_obj_t *obj ) { gui_button_t *const widget = (gui_button_t*)obj->widget; pstart(); KU_WITHOUT_ERROR_START(); if ( obj->status > GUI_NOTLOADED ) button_uload(obj); if ( widget->back_nor_name ) dfree(widget->back_nor_name); if ( widget->back_mon_name ) dfree(widget->back_mon_name); if ( widget->back_mdn_name ) dfree(widget->back_mdn_name); if ( widget->font_name ) dfree(widget->font_name); if ( widget->caption ) dfree(widget->caption); KU_WITHOUT_ERROR_STOP(); KU_ERRQ_BLOCKED(); }
/** Free the ASTER_S array. */ void free_aster(ASTER_S *aster, int naster, const PARMS_S *parms){ (void) parms; for(int iaster=0; iaster<naster; iaster++){ int ndtrat=parms->skyc.ndtrat; if(aster[iaster].kalman){ if(parms->skyc.multirate){ kalman_free(aster[iaster].kalman[0]); dcellfreearr(aster[iaster].neam, 1); }else{ for(int i=0; i<ndtrat; i++){ kalman_free(aster[iaster].kalman[i]); } dcellfreearr(aster[iaster].neam, ndtrat); } free(aster[iaster].kalman); aster[iaster].kalman=0; } dcellfree(aster[iaster].gain); dcellfree(aster[iaster].pgm); dcellfree(aster[iaster].sigman); dfree(aster[iaster].res_ws); dfree(aster[iaster].res_ngs); free(aster[iaster].wfs); dcellfree(aster[iaster].g); dfree(aster[iaster].gm); dfree(aster[iaster].dtrats); dfree(aster[iaster].idtrats); free(aster[iaster].ngs); } free(aster); }
void tkey_free (ns_tsig_key **key) { if ((*key) -> data) dfree ((*key) -> data, MDL); dfree ((*key), MDL); *key = (ns_tsig_key *)0; }
void trace_mr_statp_setup (res_state statp) { unsigned buflen = 0; char *buf = (char *)0; isc_result_t status; int i; if (trace_playback ()) { int nscount; status = trace_get_packet (&trace_mr_statp, &buflen, &buf); if (status != ISC_R_SUCCESS) { log_error ("trace_mr_statp: no statp packet found."); return; } nscount = buflen / sizeof (struct in_addr); if (nscount * (sizeof (struct in_addr)) != buflen || nscount < 1) { log_error ("trace_mr_statp: bogus length: %d", buflen); return; } if (nscount > MAXNS) nscount = MAXNS; for (i = 0; i < nscount; i++) { #if defined (HAVE_SA_LEN) statp -> nsaddr_list [i].sin_len = sizeof (struct sockaddr_in); #endif memset (&statp -> nsaddr_list [i].sin_zero, 0, sizeof statp -> nsaddr_list [i].sin_zero); statp -> nsaddr_list [i].sin_port = htons (53); /*XXX*/ statp -> nsaddr_list [i].sin_family = AF_INET; memcpy (&statp -> nsaddr_list [i].sin_addr, (buf + i * (sizeof (struct in_addr))), sizeof (struct in_addr)); } statp -> nscount = nscount; dfree (buf, MDL); buf = (char *)0; } if (trace_record ()) { trace_iov_t *iov; iov = dmalloc ((statp -> nscount * sizeof (trace_iov_t)), MDL); if (!iov) { trace_stop (); log_error ("No memory for statp iov."); return; } for (i = 0; i < statp -> nscount; i++) { iov [i].buf = (char *)&statp -> nsaddr_list [i].sin_addr; iov [i].len = sizeof (struct in_addr); } trace_write_packet_iov (trace_mr_statp, i, iov, MDL); dfree (iov, MDL); } }
static void servo_calc_free(SERVO_CALC_T *st){ cfree(st->s); cfree(st->Hol); cfree(st->Hint); cfree(st->Hsys); cfree(st->Hwfs); dfree(st->nu); dfree(st->psd); }
void fractal_vkcov_free(){ for(vkcov_t *p=head; p; p=head){ head=p->next; dfree(p->cov); dfree(p->C); dfree(p->K); dfree(p->KI); free(p); } }
void dsdict_remove(dsdict* dict, const char* key) { dsdict_node* node = dsdict_iter(dict, key); if (node) { dfree(node->key); dfree(node->value); list_erase(dict, node); free(node); } }
void testdfull (void) //************************************************************************* // //************************************************************************* { if ( (dfree(".", 0) < HOMEDISKFULL) || (dfree(m.userpath, 0) < USERDISKFULL) || (dfree(m.infopath, 0) < INFODISKFULL)) putf("***************** HDD is full ******************\n"); }
/** Free SERVO_T struct */ void servo_free(SERVO_T *st){ if(!st) return; dcellfree(st->mlead); dcellfree(st->merrlast); dcellfree(st->mpreint); cellfree(st->merrhist); cellfree(st->mint); dfree(st->ap); dfree(st->ep); free(st); }
void dsdict_free(dsdict* dict) { dsdict_node* n = dict->front; while (dict->front) { n = dict->front; dfree(n->key); dfree(n->value); dict->front = n->next; free(n); } free(dict); }
void isc_heap_destroy(isc_heap_t **heapp) { isc_heap_t *heap; REQUIRE(heapp != NULL); heap = *heapp; if (heap->array != NULL) dfree(heap->array, MDL); dfree(heap, MDL); *heapp = NULL; }
isc_result_t trace_get_file (trace_type_t *ttype, const char *filename, unsigned *len, char **buf) { fpos_t curpos; unsigned max = 0; tracepacket_t *tpkt; int status; isc_result_t result; /* Disallow some obvious bogosities. */ if (!buf || !len || *buf) return DHCP_R_INVALIDARG; /* Save file position in case of filename mismatch. */ status = fgetpos (traceinfile, &curpos); if (status < 0) log_error ("Can't save tracefile position: %m"); tpkt = dmalloc ((unsigned)tracefile_header.phlen, MDL); if (!tpkt) { log_error ("can't allocate trace packet header."); return ISC_R_NOMEMORY; } result = trace_get_next_packet (&ttype, tpkt, buf, len, &max); /* done with tpkt, free it */ dfree (tpkt, MDL); if (result != ISC_R_SUCCESS) { if (*buf) { dfree (*buf, MDL); *buf = NULL; } return result; } /* Make sure the filename is right. */ if (strcmp (filename, *buf)) { log_error ("Read file %s when expecting %s", *buf, filename); dfree (*buf, MDL); *buf = NULL; status = fsetpos (traceinfile, &curpos); if (status < 0) { log_error ("fsetpos in tracefile failed: %m"); return DHCP_R_PROTOCOLERROR; } return ISC_R_UNEXPECTEDTOKEN; } return ISC_R_SUCCESS; }
/*ARGSUSED*/ void dochngd(Char **v, struct command *c) { Char *cp; struct directory *dp; int dflag = skipargs(&v, "plvn", "[-|<dir>]"); USE(c); printd = 0; cp = (dflag & DIR_OLD) ? varval(STRowd) : *v; if (cp == NULL) { if (!cdtohome) stderror(ERR_NAME | ERR_TOOFEW); else if ((cp = varval(STRhome)) == STRNULL || *cp == 0) stderror(ERR_NAME | ERR_NOHOMEDIR); if (chdir(short2str(cp)) < 0) stderror(ERR_NAME | ERR_CANTCHANGE); cp = Strsave(cp); } else if ((dflag & DIR_OLD) == 0 && v[1] != NULL) { stderror(ERR_NAME | ERR_TOOMANY); /* NOTREACHED */ return; } else if ((dp = dfind(cp)) != 0) { char *tmp; printd = 1; if (chdir(tmp = short2str(dp->di_name)) < 0) stderror(ERR_SYSTEM, tmp, strerror(errno)); dcwd->di_prev->di_next = dcwd->di_next; dcwd->di_next->di_prev = dcwd->di_prev; dfree(dcwd); dnewcwd(dp, dflag); return; } else if ((cp = dfollow(cp, dflag & DIR_OLD)) == NULL) return; dp = xcalloc(sizeof(struct directory), 1); dp->di_name = cp; dp->di_count = 0; dp->di_next = dcwd->di_next; dp->di_prev = dcwd->di_prev; dp->di_prev->di_next = dp; dp->di_next->di_prev = dp; dfree(dcwd); dnewcwd(dp, dflag); }
/** Add two PSDs that doesn't have the same frequency. the first column of each dmat is the frequency nu, and the second column is PSD. Bug discovered on 2013-03-24:only psd2 was added to to psd.*/ static dmat *add_psd_nomatch(const dmat *psd1,const dmat *psd2){ dmat *nu1=dsub(psd1,0,psd1->nx,0,1); dmat *p2ynew=dinterp1(psd2, 0, nu1, 1e-40); dmat *psd=dnew(nu1->nx,2); double *py=psd->p+psd->nx; const double *p1y=psd1->p+psd1->nx; for(long i=0; i<psd->nx; i++){ psd->p[i]=nu1->p[i]; py[i]=p1y[i]+p2ynew->p[i]; } dfree(nu1); dfree(p2ynew); return psd; }
/** test type I/II filter with ideal measurement to make sure it is implemented correctly. */ dmat* servo_test(dmat *input, double dt, int dtrat, dmat *sigma2n, dmat *gain){ if(input->ny==1){/*single mode. each column is for a mode.*/ input->ny=input->nx; input->nx=1; } int nmod=input->nx; PDMAT(input,pinput); dmat *merr=dnew(nmod,1); dcell *mreal=cellnew(1,1); dmat *mres=dnew(nmod,input->ny); dmat *sigman=NULL; if(dnorm(sigma2n)>0){ sigman=dchol(sigma2n); } dcell *meas=cellnew(1,1); dmat *noise=dnew(nmod, 1); SERVO_T *st2t=servo_new(NULL, NULL, 0, dt*dtrat, gain); rand_t rstat; seed_rand(&rstat, 1); PDMAT(mres,pmres); /*two step delay is ensured with the order of using, copy, acc*/ for(int istep=0; istep<input->ny; istep++){ memcpy(merr->p, pinput[istep], nmod*sizeof(double)); dadd(&merr, 1, mreal->p[0], -1); memcpy(pmres[istep],merr->p,sizeof(double)*nmod); if(istep % dtrat == 0){ dzero(meas->p[0]); } dadd(&meas->p[0], 1, merr, 1);/*average the error. */ dcellcp(&mreal, st2t->mint->p[0]); if((istep+1) % dtrat == 0){ if(dtrat!=1) dscale(meas->p[0], 1./dtrat); if(sigman){ drandn(noise, 1, &rstat); if(sigman->nx>0){ dmm(&meas->p[0], 1, sigman, noise, "nn", 1); }else{ dadd(&meas->p[0], 1, noise, sigman->p[0]); } } servo_filter(st2t, meas); } } dfree(sigman); dfree(merr); dcellfree(mreal); dcellfree(meas); servo_free(st2t); return mres; }
/* Free the whole list. * * This function can't fail. */ void dlistRelease(dlist *list) { unsigned long len; dlistNode *current, *next; current = list->head; len = list->len; while(len--) { next = current->next; if (list->free) list->free(current->value); dfree(current); current = next; } dfree(list); }
/** Convert PSD into time series.*/ dmat* psd2time(const dmat *psdin, rand_t *rstat, double dt, int nstepin){ if(!psdin){ error("psdin cannot be null\n"); } long nstep=nextpow2(nstepin); double df=1./(dt*nstep); dmat *fs=dlinspace(0, df, nstep); dmat *psd=NULL; if(psdin->ny==1){//[alpha, beta, fmin, fmax] discribes power law with cut on/off freq. psd=dnew(nstep, 1); double alpha=psdin->p[0]; double beta=psdin->p[1]; long i0=1, imax=nstep; if(psdin->nx>2){ i0=(long)round(psdin->p[2]/df); if(i0<1) i0=1; } if(psdin->nx>3){ imax=(long)round(psdin->p[3]/df); } info("fmin=%g, fmax=%g, df=%g, i0=%ld, imax=%ld\n", psdin->p[2], psdin->p[3], df, i0, imax); for(long i=i0; i<imax; i++){ psd->p[i]=beta*pow(i*df, alpha); } }else if(psdin->ny==2){ if(psdin->nx<2){ error("Invalid PSD\n"); } psd=dinterp1(psdin, 0, fs, 1e-40); psd->p[0]=0;/*disable pistion. */ }else{ error("psdin is invalid format.\n"); } cmat *wshat=cnew(nstep, 1); //cfft2plan(wshat, -1); for(long i=0; i<nstep; i++){ wshat->p[i]=sqrt(psd->p[i]*df)*COMPLEX(randn(rstat), randn(rstat)); } cfft2(wshat, -1); dmat *out=NULL; creal2d(&out, 0, wshat, 1); cfree(wshat); dfree(psd); dfree(fs); dresize(out, nstepin, 1); return out; }
/** Estimate wavefront error propagated from measurement error. pgm is the reconstructor. ineam is the error inverse. trace(Mcc*(pgm*neam*pgm')) */ static dmat *calc_recon_error(const dmat *pgm, /**<[in] the reconstructor*/ const dmat *neam,/**<[in] the inverse of error covariance matrix*/ const dmat *mcc /**<[in] NGS mode covariance matrix.*/ ){ dmat *psp=NULL; dmat *tmp=NULL; dcp(&tmp, pgm); dmuldiag(tmp, neam); dmm(&psp, 0, tmp, pgm, "nt", 1); PDMAT(psp,ppsp); PDMAT(mcc,pmcc); /*It is right for both ix, iy to stop at ib.*/ double all[mcc->nx]; for(int ib=0; ib<mcc->ny; ib++){ all[ib]=0; for(int iy=0; iy<=ib; iy++){ for(int ix=0; ix<=ib; ix++){ all[ib]+=ppsp[iy][ix]*pmcc[iy][ix]; } } } dfree(psp); dmat *res=dnew(3,1); res->p[0]=all[5];//total error res->p[1]=all[1];//total TT error if(mcc->nx>5){ res->p[2]=all[5]-all[4];//focus alone if(res->p[2]<0){ res->p[2]=0;//due to coupling, this may be negative. } } return res; }
void freeZsetObject(robj *o) { zset *zs; switch (o->encoding) { case OBJ_ENCODING_SKIPLIST: zs = o->ptr; dictRelease(zs->dict); zslFree(zs->zsl); dfree(zs); break; case OBJ_ENCODING_ZIPLIST: dfree(o->ptr); break; default: serverPanic("Unknown sorted set encoding"); } }
/* * Forget what we know about an inode without removing it * * N.B: ordering of iwrite and dfree is important */ int iupdate(Icache *ic, uint32_t ino, Qid qid) { Ibuf *b; Imap *m; Dptr d; if(statson) cfsstat.nupdate++; b = iread(ic, ino); if(b == 0) return -1; /* * update inode and map */ b->inode.qid = qid; b->inode.length = 0x7fffffffffffffffLL; /* Set to maximum */ m = &ic->map[ino]; m->qid = qid; /* * the free is not done if the write fails! * this is important */ d = b->inode.ptr; b->inode.ptr.bno = Notabno; if(iwrite(ic, b) < 0) return -1; dfree(ic, &d); return 0; }
int sod_halt( sod_session *session ) { pstart(); if ( session->ecode!=SE_NONE ) { #ifdef USE_GETTEXT printf(gettext(vstr("WARNING: unmanaged error:\n\tfunction: %s\n\terror: %s\n\tcode: %d\n", \ session->errorfunc,session->errortext,session->ecode))); #else printf(vstr("WARNING: unmanaged error:\n\tfunction: %s\n\terror: %s\n\tcode: %d\n", \ session->errorfunc,session->errortext,session->ecode)); #endif } if ( session->status==SOD_CONNECTED ) { sod_disconnect(session); } dfree(session); pstop(); return SOD_OK; }
isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line) { struct group_object *group, *t; isc_result_t status; if (h -> type != dhcp_type_group) return ISC_R_INVALIDARG; group = (struct group_object *)h; if (group -> name) { if (group_name_hash) { t = (struct group_object *)0; if (group_hash_lookup (&t, group_name_hash, group -> name, strlen (group -> name), MDL)) { group_hash_delete (group_name_hash, group -> name, strlen (group -> name), MDL); group_object_dereference (&t, MDL); } } dfree (group -> name, file, line); group -> name = (char *)0; } if (group -> group) group_dereference (&group -> group, MDL); return ISC_R_SUCCESS; }
/** Setting up aperture cordinate grid aper_locs, and amplitude map for performance evaluation. */ APER_T * setup_aper(const PARMS_T *const parms){ APER_T *aper = mycalloc(1,APER_T); tic; if(parms->aper.fnamp){ info2("Reading aperture amplitude map from %s\n", parms->aper.fnamp); aper->ampground=mapread("%s",parms->aper.fnamp); if(fabs(aper->ampground->h)>1.e-14){ warning("ampground is not on ground, this is not tested\n"); }else{ double amp_d, amp_din; map_d_din(aper->ampground, &_d, &_din); if(fabs(parms->aper.d - amp_d) > 1 || fabs(parms->aper.din - amp_din) > 0.5){ if(!parms->aper.fnampuser){ warning2("Amplitude map does not match aperture diameter: amp.d=(%g, %g) aper.d=(%g, %g). Disabled\n", amp_d, amp_din, parms->aper.d, parms->aper.din); mapfree(aper->ampground); free(((PARMS_T*)parms)->aper.fnamp); ((PARMS_T*)parms)->aper.fnamp=0; }else{ error("Use supplied amplitude map does not match aperture diameter: amp.d=(%g, %g) aper.d=(%g, %g).\n", amp_d, amp_din, parms->aper.d, parms->aper.din); } } } if(fabs(parms->aper.rotdeg)>1.e-12){ warning("Pupil is rotated by %g deg\n",parms->aper.rotdeg); const long nx=aper->ampground->nx; const long ny=aper->ampground->ny; dmat *B=dnew_data(nx, ny, aper->ampground->p); aper->ampground->p=mycalloc(nx*ny,double); dembed((dmat*)aper->ampground,B,parms->aper.rotdeg/180.*M_PI); dfree(B); }
isc_result_t dns_zone_lookup (struct dns_zone **zone, const char *name) { struct dns_zone *tz = (struct dns_zone *)0; int len; char *tname = (char *)0; isc_result_t status; if (!dns_zone_hash) return ISC_R_NOTFOUND; len = strlen (name); if (name [len - 1] != '.') { tname = dmalloc ((unsigned)len + 2, MDL); if (!tname) return ISC_R_NOMEMORY;; strcpy (tname, name); tname [len] = '.'; tname [len + 1] = 0; name = tname; } if (!dns_zone_hash_lookup (zone, dns_zone_hash, name, 0, MDL)) status = ISC_R_NOTFOUND; else status = ISC_R_SUCCESS; if (tname) dfree (tname, MDL); return status; }
void CWorldClientBSP::Term() { //deallocate structures. //term our world tree. world_tree.Term(); //if we are inherited from the server, delete our worldmodels special if (inherited_from_server == true) { //check each worldmodel. for (uint32 i = 0; i < num_world_models; i++) { //get the worldmodel. WorldData *worldmodel = world_models[i]; if (worldmodel == NULL) continue; //clear the worldmodel that was inherited. worldmodel->TermInherited(); } } //delete our world models and clear the array. for (uint32 i = 0; i < num_world_models; i++) { delc(world_models[i]); } dfree(world_models); //clear integral typed vars. Clear(); //we are not using the shared world data any more world_bsp_shared->used_by_client = false; //terminate the shared world data. world_bsp_shared->Term(); }
void d3d_TermPolyGridDraw() { dfree(g_TriVertList); g_TriVertList = LTNULL; g_TriVertListSize = 0; }