diff --git a/ChangeLog b/ChangeLog index 91ebef5df..759c33c9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-10-28 Robert Larice + * src/**/* : + wrap tmalloc MALLOC etc, into two macros TMALLOC and TREALLOC + add casts to those macros to silence type conversion warnings + 2010-10-28 Robert Larice * src/frontend/commands.c , * src/frontend/control.c : diff --git a/src/ciderlib/input/doping.c b/src/ciderlib/input/doping.c index ef9d0a96d..7f5e6d9d5 100644 --- a/src/ciderlib/input/doping.c +++ b/src/ciderlib/input/doping.c @@ -107,7 +107,7 @@ DOPparam(int param, IFvalue *value, void *inCard) case DOP_DOMAIN: if ( !card->DOPdomainsGiven ) { card->DOPnumDomains = value->v.numValue; - card->DOPdomains = (int *)tmalloc(value->v.numValue * sizeof(int)); + card->DOPdomains = TMALLOC(int, value->v.numValue); for ( i=0; i < card->DOPnumDomains; i++ ) { card->DOPdomains[i] = value->v.vec.iVec[i]; } diff --git a/src/ciderlib/support/database.c b/src/ciderlib/support/database.c index 3b3fff37d..737ff305d 100644 --- a/src/ciderlib/support/database.c +++ b/src/ciderlib/support/database.c @@ -36,7 +36,7 @@ DBgetData(struct plot *plot, char *name, int lengthWanted) return(NULL); } - data = (double *) tmalloc(sizeof (double) * v->v_length); + data = TMALLOC(double, v->v_length); if (isreal(v)) { bcopy(v->v_realdata, data, sizeof (double) * v->v_length); } else { diff --git a/src/frontend/arg.c b/src/frontend/arg.c index 22c20c504..6224c8313 100644 --- a/src/frontend/arg.c +++ b/src/frontend/arg.c @@ -31,7 +31,7 @@ char *prompt(FILE *fp) return 0; n = strlen(buf) - 1; buf[n] = '\0'; /* fgets leaves the \n */ - p = (char *) tmalloc(n + 1); + p = TMALLOC(char, n + 1); strcpy(p, buf); return p; } diff --git a/src/frontend/breakp2.c b/src/frontend/breakp2.c index 228b82dd0..3e56f74d3 100644 --- a/src/frontend/breakp2.c +++ b/src/frontend/breakp2.c @@ -112,8 +112,7 @@ ft_getSaves(struct save_info **savesp) if (!count) return (0); - *savesp = array = (struct save_info *) - tmalloc(sizeof (struct save_info) * count); + *savesp = array = TMALLOC(struct save_info, count); for (d = dbs; d; d = d->db_next) if (d->db_type == DB_SAVE) { diff --git a/src/frontend/com_compose.c b/src/frontend/com_compose.c index 25c03db30..6fd916db5 100644 --- a/src/frontend/com_compose.c +++ b/src/frontend/com_compose.c @@ -180,11 +180,9 @@ com_compose(wordlist *wl) for (i = 0, blocksize = 1; i < dim - 1; i++) blocksize *= dims[i]; if (realflag) - data = (double *) tmalloc(sizeof (double) * (length * - blocksize)); + data = TMALLOC(double, length * blocksize); else - cdata = (ngcomplex_t *) tmalloc(sizeof(ngcomplex_t) * (length * - blocksize)); + cdata = TMALLOC(ngcomplex_t, length * blocksize); /* Now copy all the data over... If the sizes are too small * then the extra elements are left as 0. @@ -416,7 +414,7 @@ com_compose(wordlist *wl) } if (lingiven) { /* Create a linear sweep... */ - data = (double *) tmalloc(sizeof (double) * (int) lin); + data = TMALLOC(double, (int) lin); if (stepgiven && startgiven && stopgiven) { if (step != (stop - start) / lin * (reverse ? -1 : 1)) { diff --git a/src/frontend/com_display.c b/src/frontend/com_display.c index fb53c8e3a..8072ab946 100644 --- a/src/frontend/com_display.c +++ b/src/frontend/com_display.c @@ -61,7 +61,7 @@ com_display(wordlist *wl) return; } out_printf("Here are the vectors currently active:\n\n"); - dvs = (struct dvec **) tmalloc(len * sizeof(struct dvec *)); + dvs = TMALLOC(struct dvec *, len); for (d = plot_cur->pl_dvecs, i = 0; d; d = d->v_next, i++) dvs[i] = d; if (!cp_getvar("nosort", CP_BOOL, NULL)) diff --git a/src/frontend/com_fft.c b/src/frontend/com_fft.c index a81ce1fef..4708ec727 100644 --- a/src/frontend/com_fft.c +++ b/src/frontend/com_fft.c @@ -59,7 +59,7 @@ com_fft(wordlist *wl) fpts = size/2; /* window functions - should have an average of one */ - win = (double *) tmalloc(tlen * sizeof (double)); + win = TMALLOC(double, tlen); { char window[BSIZE_SP]; double maxt = time[tlen-1]; @@ -188,7 +188,7 @@ com_fft(wordlist *wl) plot_cur->pl_name = copy("Spectrum"); plot_cur->pl_date = copy(datestring( )); - freq = (double *) tmalloc(fpts * sizeof(double)); + freq = TMALLOC(double, fpts); f = alloc(struct dvec); ZERO(f, struct dvec); f->v_name = copy("frequency"); @@ -201,11 +201,11 @@ com_fft(wordlist *wl) for (i = 0; iv_realdata; /* real input data */ - fdvec[i] = (ngcomplex_t *) tmalloc(fpts * sizeof(ngcomplex_t)); /* complex output data */ + fdvec[i] = TMALLOC(ngcomplex_t, fpts); /* complex output data */ f = alloc(struct dvec); ZERO(f, struct dvec); f->v_name = vec_basename(vec); @@ -222,8 +222,8 @@ com_fft(wordlist *wl) printf("FFT: Time span: %g s, input length: %d, zero padding: %d\n", span, size, size-tlen); printf("FFT: Freq. resolution: %g Hz, output length: %d\n", 1.0/span*tlen/size, fpts); - reald = (double*)tmalloc(size*sizeof(double)); - imagd = (double*)tmalloc(size*sizeof(double)); + reald = TMALLOC(double, size); + imagd = TMALLOC(double, size); for (i = 0; iwl_word = buf2; wl->wl_next = NULL; wl = process(wl); diff --git a/src/frontend/com_let.c b/src/frontend/com_let.c index 60b9c3c18..81fcf0bff 100644 --- a/src/frontend/com_let.c +++ b/src/frontend/com_let.c @@ -166,9 +166,9 @@ com_let(wordlist *wl) } if (isreal(t)) - n->v_realdata = (double *) tmalloc(n->v_length * sizeof(double)); + n->v_realdata = TMALLOC(double, n->v_length); else - n->v_compdata = (ngcomplex_t *) tmalloc(n->v_length * sizeof(ngcomplex_t)); + n->v_compdata = TMALLOC(ngcomplex_t, n->v_length); newvec = 1; vec_new(n); } diff --git a/src/frontend/com_measure2.c b/src/frontend/com_measure2.c index dd5b5bc95..0817578be 100644 --- a/src/frontend/com_measure2.c +++ b/src/frontend/com_measure2.c @@ -786,9 +786,9 @@ static void measure_rms_integral( } /* Allocate buffers for calculation. */ - x = (double *) tmalloc(xScale->v_length * sizeof(double)); - y = (double *) tmalloc(xScale->v_length * sizeof(double)); - width = (double *) tmalloc((xScale->v_length + 1) * sizeof(double)); + x = TMALLOC(double, xScale->v_length); + y = TMALLOC(double, xScale->v_length); + width = TMALLOC(double, xScale->v_length + 1); xy_size = 0 ; toVal = -1 ; @@ -1394,8 +1394,8 @@ get_measure2( { // trig parameters MEASUREPTR measTrig, measTarg; - measTrig = (struct measure*)tmalloc(sizeof(struct measure)); - measTarg = (struct measure*)tmalloc(sizeof(struct measure)); + measTrig = TMALLOC(struct measure, 1); + measTarg = TMALLOC(struct measure, 1); measTrig->m_analysis = measTarg->m_analysis = mAnalysis; @@ -1463,8 +1463,8 @@ get_measure2( case AT_FIND: { MEASUREPTR meas, measFind; - meas = (struct measure*)tmalloc(sizeof(struct measure)); - measFind = (struct measure*)tmalloc(sizeof(struct measure)); + meas = TMALLOC(struct measure, 1); + measFind = TMALLOC(struct measure, 1); meas->m_analysis = measFind->m_analysis = mAnalysis; @@ -1519,7 +1519,7 @@ get_measure2( case AT_WHEN: { MEASUREPTR meas; - meas = (struct measure*)tmalloc(sizeof(struct measure)); + meas = TMALLOC(struct measure, 1); meas->m_analysis = mAnalysis; if (measure_parse_when(meas, words, errbuf) ==0) { measure_errMessage(mName, mFunction, "WHEN", errbuf, autocheck); @@ -1549,7 +1549,7 @@ get_measure2( { // trig parameters MEASUREPTR meas; - meas = (struct measure*)tmalloc(sizeof(struct measure)); + meas = TMALLOC(struct measure, 1); meas->m_analysis = mAnalysis; if (measure_parse_trigtarg(meas, words , NULL, "trig", errbuf)==0) { measure_errMessage(mName, mFunction, "TRIG", errbuf, autocheck); @@ -1582,7 +1582,7 @@ get_measure2( { // trig parameters MEASUREPTR meas; - meas = (struct measure*)tmalloc(sizeof(struct measure)); + meas = TMALLOC(struct measure, 1); meas->m_analysis = mAnalysis; @@ -1619,7 +1619,7 @@ get_measure2( { // trig parameters MEASUREPTR measTrig; - measTrig = (struct measure*)tmalloc(sizeof(struct measure)); + measTrig = TMALLOC(struct measure, 1); measTrig->m_analysis = mAnalysis; if (measure_parse_trigtarg(measTrig, words , NULL, "trig", errbuf)==0) { measure_errMessage(mName, mFunction, "TRIG", errbuf, autocheck); @@ -1661,7 +1661,7 @@ get_measure2( { double minValue, maxValue; MEASUREPTR measTrig; - measTrig = (struct measure*)tmalloc(sizeof(struct measure)); + measTrig = TMALLOC(struct measure, 1); measTrig->m_analysis = mAnalysis; if (measure_parse_trigtarg(measTrig, words , NULL, "trig", errbuf)==0) { measure_errMessage(mName, mFunction, "TRIG", errbuf, autocheck); diff --git a/src/frontend/com_sysinfo.c b/src/frontend/com_sysinfo.c index e1f8d9dd2..1e8df3f7a 100644 --- a/src/frontend/com_sysinfo.c +++ b/src/frontend/com_sysinfo.c @@ -90,7 +90,7 @@ void com_sysinfo(wordlist *wl) int errorcode; TesSystemInfo* info; - info = (TesSystemInfo*)tmalloc(sizeof(TesSystemInfo)); + info = TMALLOC(TesSystemInfo, 1); errorcode = tesCreateSystemInfo(info); if (errorcode) @@ -457,7 +457,7 @@ TesError tesCreateSystemInfo(TesSystemInfo *info) { } RegQueryValueExA(hkBaseCPU,"ProcessorNameString",0,0,NULL,&dwLen); - freeStr = procStr = (char*) tmalloc(dwLen+1); + freeStr = procStr = TMALLOC(char, dwLen + 1); RegQueryValueExA(hkBaseCPU,"ProcessorNameString",0,0,(LPBYTE)procStr,&dwLen); procStr[dwLen] = '\0'; while (*procStr == ' ') procStr++; diff --git a/src/frontend/define.c b/src/frontend/define.c index 40582c2b4..f9b4a4bf3 100644 --- a/src/frontend/define.c +++ b/src/frontend/define.c @@ -164,14 +164,12 @@ savetree(struct pnode *pn) pn->pn_value->v_flags = d->v_flags; pn->pn_value->v_plot = d->v_plot; if (isreal(d)) { - pn->pn_value->v_realdata = (double *) - tmalloc(sizeof (double) * d->v_length); + pn->pn_value->v_realdata = TMALLOC(double, d->v_length); bcopy(d->v_realdata, pn->pn_value->v_realdata, sizeof (double) * d->v_length); } else { - pn->pn_value->v_compdata = (ngcomplex_t *) - tmalloc(sizeof(ngcomplex_t) * d->v_length); + pn->pn_value->v_compdata = TMALLOC(ngcomplex_t, d->v_length); bcopy(d->v_compdata, pn->pn_value->v_compdata, sizeof(ngcomplex_t) * d->v_length); diff --git a/src/frontend/device.c b/src/frontend/device.c index 3cf5004b6..5283d3949 100644 --- a/src/frontend/device.c +++ b/src/frontend/device.c @@ -915,10 +915,10 @@ com_alter_common(wordlist *wl, int do_model) if(argument[i]!='\0'){ /* We found '=' */ eqfound = TRUE; - arglist = (char**)tmalloc(4*sizeof(char*)); + arglist = TMALLOC(char*, 4); arglist[3] = NULL; - arglist[0] = (char*)tmalloc(i + 1); - arglist[2] = (char*)tmalloc(strlen(&argument[i+1]) + 1); + arglist[0] = TMALLOC(char, i + 1); + arglist[2] = TMALLOC(char, strlen(&argument[i + 1]) + 1); /* copy argument */ strncpy(arglist[0],argument,i); arglist[0][i] = '\0'; @@ -981,7 +981,7 @@ com_alter_common(wordlist *wl, int do_model) } /* add the '=' */ /* create wordlist with '=' */ - wleq = (wordlist*)tmalloc(sizeof(wordlist)); + wleq = TMALLOC(wordlist, 1); wleq->wl_word = copy("="); /* add the last element (the value of the param - value pair) */ wleq->wl_next = wlin; @@ -1068,17 +1068,17 @@ com_alter_common(wordlist *wl, int do_model) if(eq(words->wl_word, "[")) words = words->wl_next; xsbuf = wl_flatten(words); /* fprintf(cp_err, "Chain converted %s \n",xsbuf); */ - dv=(struct dvec *)MALLOC(sizeof(struct dvec)); + dv = TMALLOC(struct dvec, 1); dv->v_name = copy("real vector"); type &= IF_VARTYPES; if (type == IF_REALVEC) { - list = (double *)MALLOC(sizeof(double)); + list = TMALLOC(double, 1); tmp = INPevaluate(&xsbuf,&error,1); while (error == 0) { /*printf(" returning vector value %g\n",tmp); */ i++; - list=(double *)REALLOC((char *)list,i*sizeof(double)); + list=TREALLOC(double, list, i); *(list+i-1) = tmp; tmp = INPevaluate(&xsbuf,&error,1); } diff --git a/src/frontend/display.c b/src/frontend/display.c index a2844d1a9..7da72212a 100644 --- a/src/frontend/display.c +++ b/src/frontend/display.c @@ -354,7 +354,7 @@ void SaveText(GRAPH *graph, char *text, int x, int y) struct _keyed *keyed; - keyed = (struct _keyed *) tmalloc(sizeof(struct _keyed)); + keyed = TMALLOC(struct _keyed, 1); if (!graph->keyed) { graph->keyed = keyed; @@ -363,7 +363,7 @@ void SaveText(GRAPH *graph, char *text, int x, int y) graph->keyed = keyed; } - keyed->text = (char*) tmalloc(strlen(text) + 1); + keyed->text = TMALLOC(char, strlen(text) + 1); strcpy(keyed->text, text); keyed->x = x; diff --git a/src/frontend/evaluate.c b/src/frontend/evaluate.c index 0d84b00e3..349d716f6 100644 --- a/src/frontend/evaluate.c +++ b/src/frontend/evaluate.c @@ -224,7 +224,7 @@ doop(char what, free1 = TRUE; if (isreal(v1)) { ld = 0.0; - d1 = (double *) tmalloc(length * sizeof (double)); + d1 = TMALLOC(double, length); for (i = 0; i < v1->v_length; i++) d1[i] = v1->v_realdata[i]; if (i > 0) @@ -234,7 +234,7 @@ doop(char what, } else { realpart(&lc) = 0.0; imagpart(&lc) = 0.0; - c1 = (ngcomplex_t *) tmalloc(length * sizeof(ngcomplex_t)); + c1 = TMALLOC(ngcomplex_t, length); for (i = 0; i < v1->v_length; i++) c1[i] = v1->v_compdata[i]; if (i > 0) @@ -251,7 +251,7 @@ doop(char what, free2 = TRUE; if (isreal(v2)) { ld = 0.0; - d2 = (double *) tmalloc(length * sizeof (double)); + d2 = TMALLOC(double, length); for (i = 0; i < v2->v_length; i++) d2[i] = v2->v_realdata[i]; if (i > 0) @@ -261,7 +261,7 @@ doop(char what, } else { realpart(&lc) = 0.0; imagpart(&lc) = 0.0; - c2 = (ngcomplex_t *) tmalloc(length * sizeof(ngcomplex_t)); + c2 = TMALLOC(ngcomplex_t, length); for (i = 0; i < v2->v_length; i++) c2[i] = v2->v_compdata[i]; if (i > 0) @@ -601,9 +601,9 @@ op_range(struct pnode *arg1, struct pnode *arg2) res->v_dims[0] = len; if (isreal(res)) - res->v_realdata = (double *) tmalloc(sizeof (double) * len); + res->v_realdata = TMALLOC(double, len); else - res->v_compdata = (ngcomplex_t *) tmalloc(sizeof(ngcomplex_t) * len); + res->v_compdata = TMALLOC(ngcomplex_t, len); /* Toss in the data */ @@ -752,9 +752,9 @@ op_ind(struct pnode *arg1, struct pnode *arg2) } if (isreal(res)) - res->v_realdata = (double *) tmalloc(sizeof (double) * length); + res->v_realdata = TMALLOC(double, length); else - res->v_compdata = (ngcomplex_t *) tmalloc(sizeof(ngcomplex_t) * length); + res->v_compdata = TMALLOC(ngcomplex_t, length); /* And toss in the new data */ for (j = 0; j < up - down + 1; j++) { diff --git a/src/frontend/fourier.c b/src/frontend/fourier.c index dd54ff79a..93a564176 100644 --- a/src/frontend/fourier.c +++ b/src/frontend/fourier.c @@ -83,11 +83,11 @@ fourier(wordlist *wl, struct plot *current_plot) } fundfreq = *ff; - freq = (double *) tmalloc(nfreqs * sizeof (double)); - mag = (double *) tmalloc(nfreqs * sizeof (double)); - phase = (double *) tmalloc(nfreqs * sizeof (double)); - nmag = (double *) tmalloc(nfreqs * sizeof (double)); - nphase = (double *) tmalloc(nfreqs * sizeof (double)); + freq = TMALLOC(double, nfreqs); + mag = TMALLOC(double, nfreqs); + phase = TMALLOC(double, nfreqs); + nmag = TMALLOC(double, nfreqs); + nphase = TMALLOC(double, nfreqs); wl = wl->wl_next; names = ft_getpnames(wl, TRUE); @@ -110,10 +110,8 @@ fourier(wordlist *wl, struct plot *current_plot) if (polydegree) { /* Build the grid... */ - grid = (double *) tmalloc(fourgridsize * - sizeof (double)); - stuff = (double *) tmalloc(fourgridsize * - sizeof (double)); + grid = TMALLOC(double, fourgridsize); + stuff = TMALLOC(double, fourgridsize); dp = ft_minmax(time, TRUE); /* Now get the last fund freq... */ diff --git a/src/frontend/help/help.c b/src/frontend/help/help.c index 07237e742..002ba7e80 100644 --- a/src/frontend/help/help.c +++ b/src/frontend/help/help.c @@ -75,7 +75,7 @@ findglobalsubject(char *subject) for (dict = hlp_filelist; *dict && **dict; dict++) { fpos = findsubject(*dict, subject); if (fpos != -1) { - place = (fplace *) tmalloc(sizeof(fplace)); + place = TMALLOC(fplace, 1); place->fpos = fpos; place->filename = copy(*dict); place->fp = hlp_fopen(*dict); diff --git a/src/frontend/help/readhelp.c b/src/frontend/help/readhelp.c index c0b6fa5cf..2c2a828d0 100644 --- a/src/frontend/help/readhelp.c +++ b/src/frontend/help/readhelp.c @@ -48,7 +48,7 @@ sortlist(toplink **tlp) num++; if (!num) return; - vec = (toplink **) tmalloc(sizeof (toplink *) * num); + vec = TMALLOC(toplink *, num); for (tl = *tlp, i = 0; tl; tl = tl->next, i++) vec[i] = tl; (void) qsort(vec, num, sizeof (toplink *), sortcmp); @@ -188,7 +188,7 @@ static toplink *getsubtoplink(char **ss) if ((tmp =strchr(s, ':'))) { tl->place = alloc(fplace); tl->place->filename = strncpy( - (char*) tmalloc(sizeof (char) * (tmp - s + 1)), + TMALLOC(char, tmp - s + 1), s, (tmp - s)); tl->place->filename[tmp - s] = '\0'; strtolower(tl->place->filename); @@ -354,7 +354,7 @@ copy_fplace(fplace *place) { fplace *newplace; - newplace = (fplace *) tmalloc(sizeof(fplace)); + newplace = TMALLOC(fplace, 1); newplace->filename = copy(place->filename); newplace->fpos = place->fpos; newplace->fp = place->fp; diff --git a/src/frontend/help/x11disp.c b/src/frontend/help/x11disp.c index c336c5b93..8a2e2eeeb 100644 --- a/src/frontend/help/x11disp.c +++ b/src/frontend/help/x11disp.c @@ -123,7 +123,7 @@ hlp_xdisplay(topic *top) top->titlewidget, buttonargs, XtNumber(buttonargs)); XtAddCallback(buttonwidget, XtNcallback, (XtCallbackProc) delete, top); - buf = (char*) tmalloc(80 * top->numlines + 100); + buf = TMALLOC(char, 80 * top->numlines + 100); buf[0] = '\0'; for (wl = top->text; wl; wl = wl->wl_next) { sputline(buf, wl->wl_word); @@ -164,7 +164,7 @@ hlp_xdisplay(topic *top) commandWidgetClass, top->subboxwidget, buttonargs, XtNumber(buttonargs)); /* core leak XXX */ - hand = (handle *) tmalloc(sizeof (handle)); + hand = TMALLOC(handle, 1); hand->result = tl; hand->parent = top; XtAddCallback(buttonwidget, XtNcallback, (XtCallbackProc) newtopic, hand); @@ -196,7 +196,7 @@ hlp_xdisplay(topic *top) XtSetArg(buttonargs[0], XtNlabel, tl->button.text); buttonwidget = XtCreateManagedWidget(tl->button.text, commandWidgetClass, top->seeboxwidget, buttonargs, 1); - hand = (handle *) tmalloc(sizeof (handle)); + hand = TMALLOC(handle, 1); /* core leak XXX */ hand->result = tl; hand->parent = top; diff --git a/src/frontend/hpgl.c b/src/frontend/hpgl.c index 4a25bedd6..92a249c3d 100644 --- a/src/frontend/hpgl.c +++ b/src/frontend/hpgl.c @@ -154,7 +154,7 @@ GRAPH *graph) if (!screenflag) #endif - graph->devdep = (GLdevdep*) tmalloc(sizeof(GLdevdep)); + graph->devdep = TMALLOC(GLdevdep, 1); DEVDEP(graph).lastlinestyle = -1; DEVDEP(graph).lastx = -1; DEVDEP(graph).lasty = -1; diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 15942b197..a3d218106 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -130,7 +130,7 @@ readline(FILE *fd) strptr = NULL; strlen = 0; memlen = STRGROW; - strptr = (char*) tmalloc(memlen); + strptr = TMALLOC(char, memlen); memlen -= 1; /* Save constant -1's in while loop */ while((c = getc(fd)) != EOF) { if (strlen == 0 && (c == '\t' || c == ' ')) /* Leading spaces away */ @@ -139,7 +139,7 @@ readline(FILE *fd) strlen++; if( strlen >= memlen ) { memlen += STRGROW; - if( !(strptr = (char*) trealloc(strptr, (memlen + 1)*sizeof(char)))) { + if( !(strptr = TREALLOC(char, strptr, memlen + 1))) { return (NULL); } } @@ -153,7 +153,7 @@ readline(FILE *fd) } // strptr[strlen] = '\0'; /* Trim the string */ - strptr = (char*) trealloc(strptr, (strlen + 1)*sizeof(char)); + strptr = TREALLOC(char, strptr, strlen + 1); strptr[strlen] = '\0'; return (strptr); } @@ -400,7 +400,7 @@ inp_add_control_section( struct line *deck, int *line_number ) { found_run = TRUE; } if ( cp_getvar( "rawfile", CP_STRING, rawfile ) ) { - line = (char*) tmalloc( strlen("write") + strlen(rawfile) + 2 ); + line = TMALLOC(char, strlen("write") + strlen(rawfile) + 2); sprintf(line, "write %s", rawfile); newcard = create_new_card( line, line_number ); prev_card->li_next = newcard; @@ -419,7 +419,7 @@ inp_add_control_section( struct line *deck, int *line_number ) { newcard->li_next = prev_card; if ( cp_getvar( "rawfile", CP_STRING, rawfile ) ) { - line = (char*) tmalloc( strlen("write") + strlen(rawfile) + 2 ); + line = TMALLOC(char, strlen("write") + strlen(rawfile) + 2); sprintf(line, "write %s", rawfile); prev_card = deck->li_next; newcard = create_new_card( line, line_number ); @@ -486,10 +486,10 @@ inp_fix_macro_param_func_paren_io( struct line *begin_card ) { while( !isspace(*str_ptr) ) str_ptr++; if ( ciprefix( ".macro", card->li_line ) ) { - new_str = (char*) tmalloc( strlen(".subckt") + strlen(str_ptr) + 1 ); + new_str = TMALLOC(char, strlen(".subckt") + strlen(str_ptr) + 1); sprintf( new_str, ".subckt%s", str_ptr ); } else { - new_str = (char*) tmalloc( strlen(".ends") + strlen(str_ptr) + 1 ); + new_str = TMALLOC(char, strlen(".ends") + strlen(str_ptr) + 1); sprintf( new_str, ".ends%s", str_ptr ); } @@ -751,8 +751,8 @@ comment_out_unused_subckt_models( struct line *start_card , int no_of_lines) /* generate arrays of *char for subckt or model names. Start with 1000, but increase, if number of lines in deck is larger */ if (no_of_lines < 1000) no_of_lines = 1000; - used_subckt_names = (char**)tmalloc(no_of_lines*sizeof(char*)); - used_model_names = (char**)tmalloc(no_of_lines*sizeof(char*)); + used_subckt_names = TMALLOC(char*, no_of_lines); + used_model_names = TMALLOC(char*, no_of_lines); for ( card = start_card; card != NULL; card = card->li_next ) { if ( ciprefix( ".model", card->li_line ) ) has_models = TRUE; @@ -1005,19 +1005,19 @@ inp_fix_ternary_operator_str( char *line ) if ( end_str != NULL ) { if ( beg_str != NULL ) { - new_str = (char*) tmalloc( strlen(beg_str) + strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + strlen(end_str) + 5 ); + new_str = TMALLOC(char, strlen(beg_str) + strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + strlen(end_str) + 5); sprintf( new_str, "%sternary_fcn(%s,%s,%s)%s", beg_str, conditional, if_str, else_str, end_str ); } else { - new_str = (char*) tmalloc( strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + strlen(end_str) + 5 ); + new_str = TMALLOC(char, strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + strlen(end_str) + 5); sprintf( new_str, "ternary_fcn(%s,%s,%s)%s", conditional, if_str, else_str, end_str ); } } else { if ( beg_str != NULL ) { - new_str = (char*) tmalloc( strlen(beg_str) + strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + 5 ); + new_str = TMALLOC(char, strlen(beg_str) + strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + 5); sprintf( new_str, "%sternary_fcn(%s,%s,%s)", beg_str, conditional, if_str, else_str ); } else { - new_str = (char*) tmalloc( strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + 5 ); + new_str = TMALLOC(char, strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + 5); sprintf( new_str, "ternary_fcn(%s,%s,%s)", conditional, if_str, else_str ); } } @@ -1115,7 +1115,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c if ( call_depth == 0 && line_count == 0 ) { line_count++; if ( fgets( big_buff, 5000, fp ) ) { -/* buffer = (char*) tmalloc( strlen(big_buff) + 1 ); +/* buffer = TMALLOC(char, strlen(big_buff) + 1); strcpy(buffer, big_buff); */ buffer = copy(big_buff); } @@ -1137,7 +1137,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c break; } else if(ipc_status == IPC_STATUS_OK) { - buffer = (char *) tmalloc(strlen(ipc_buffer) + 3); + buffer = TMALLOC(char, strlen(ipc_buffer) + 3); strcpy(buffer, ipc_buffer); strcat(buffer, "\n"); } @@ -1375,7 +1375,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c } if ( shell_eol_continuation ) { - char *new_buffer = (char*) tmalloc( strlen(buffer) + 2); + char *new_buffer = TMALLOC(char, strlen(buffer) + 2); sprintf( new_buffer, "+%s", buffer ); tfree(buffer); @@ -1410,7 +1410,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c if ( call_depth == 0 && found_end == TRUE) { if ( global == NULL ) { - global = (char*) tmalloc( strlen(".global gnd") + 1 ); + global = TMALLOC(char, strlen(".global gnd") + 1); sprintf( global, ".global gnd" ); } global_card = alloc(struct line); @@ -1507,7 +1507,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c end->li_next = alloc(struct line); /* create next card */ end = end->li_next; /* point to next card */ - buffer = (char*) tmalloc( strlen( ".end" ) + 1 ); + buffer = TMALLOC(char, strlen( ".end" ) + 1); sprintf( buffer, ".end" ); /* now put buffer into li */ @@ -1565,7 +1565,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c } /* create buffer and write last and current line into it. */ - buffer = (char*) tmalloc(strlen(prev->li_line) + strlen(s) + 2); + buffer = TMALLOC(char, strlen(prev->li_line) + strlen(s) + 2); (void) sprintf(buffer, "%s %s", prev->li_line, s + 1); s = prev->li_line; @@ -1893,7 +1893,7 @@ inp_fix_subckt( char *s ) if ( new_str == NULL ) new_str = strdup(c->li_line); else { str = new_str; - new_str = (char*) tmalloc( strlen(str) + strlen(c->li_line) + 2 ); + new_str = TMALLOC(char, strlen(str) + strlen(c->li_line) + 2); sprintf( new_str, "%s %s", str, c->li_line ); tfree(str); } @@ -1904,7 +1904,7 @@ inp_fix_subckt( char *s ) } /* create buffer and insert params: */ - buffer = (char*) tmalloc( strlen(s) + 9 + strlen(new_str) + 1 ); + buffer = TMALLOC(char, strlen(s) + 9 + strlen(new_str) + 1); sprintf( buffer, "%s params: %s", s, new_str ); tfree(s); tfree(new_str); @@ -1922,7 +1922,7 @@ inp_remove_ws( char *s ) char *buffer, *curr; bool is_expression = FALSE; - big_buff = (char*) tmalloc( strlen(s) + 1 ); + big_buff = TMALLOC(char, strlen(s) + 1); curr = s; while ( *curr != '\0' ) { @@ -2213,7 +2213,7 @@ inp_fix_inst_line( char *inst_line, } for ( i = 0; i < num_subckt_params; i++ ) { - new_line = (char*) tmalloc( strlen( curr_line ) + strlen( subckt_param_values[i] ) + 2 ); + new_line = TMALLOC(char, strlen( curr_line ) + strlen( subckt_param_values[i] ) + 2); sprintf( new_line, "%s %s", curr_line, subckt_param_values[i] ); tfree( curr_line ); @@ -2259,11 +2259,11 @@ inp_fix_subckt_multiplier( struct line *subckt_card, num_subckt_params = num_subckt_params + 1; if ( !strstr( subckt_card->li_line, "params:" ) ) { - new_str = (char*) tmalloc( strlen( subckt_card->li_line ) + 13 ); + new_str = TMALLOC(char, strlen( subckt_card->li_line ) + 13); sprintf( new_str, "%s params: m=1", subckt_card->li_line ); subckt_w_params[num_subckt_w_params++] = get_subckt_model_name( subckt_card->li_line ); } else { - new_str = (char*) tmalloc( strlen( subckt_card->li_line ) + 5 ); + new_str = TMALLOC(char, strlen( subckt_card->li_line ) + 5); sprintf( new_str, "%s m=1", subckt_card->li_line ); } @@ -2276,7 +2276,7 @@ inp_fix_subckt_multiplier( struct line *subckt_card, /* no 'm' for B line or comment line */ if ((*(card->li_line) == '*') || (*(card->li_line) == 'b')) continue; - new_str = (char*) tmalloc( strlen( card->li_line ) + 7 ); + new_str = TMALLOC(char, strlen( card->li_line ) + 7); sprintf( new_str, "%s m={m}", card->li_line ); tfree( card->li_line ); @@ -2552,20 +2552,20 @@ inp_do_macro_param_replace( int fcn_number, char *params[] ) if ( curr_str != NULL ) { if ( str_has_arith_char( params[i] ) ) { - new_str = (char*) tmalloc( strlen(curr_str) + strlen(curr_ptr) + strlen(params[i]) + 3 ); + new_str = TMALLOC(char, strlen(curr_str) + strlen(curr_ptr) + strlen(params[i]) + 3); sprintf( new_str, "%s%s(%s)", curr_str, curr_ptr, params[i] ); } else { - new_str = (char*) tmalloc( strlen(curr_str) + strlen(curr_ptr) + strlen(params[i]) + 1 ); + new_str = TMALLOC(char, strlen(curr_str) + strlen(curr_ptr) + strlen(params[i]) + 1); sprintf( new_str, "%s%s%s", curr_str, curr_ptr, params[i] ); } tfree( curr_str ); } else { if ( str_has_arith_char( params[i] ) ) { - new_str = (char*) tmalloc( strlen(curr_ptr) + strlen(params[i]) + 3 ); + new_str = TMALLOC(char, strlen(curr_ptr) + strlen(params[i]) + 3); sprintf( new_str, "%s(%s)", curr_ptr, params[i] ); } else { - new_str = (char*) tmalloc( strlen(curr_ptr) + strlen(params[i]) + 1 ); + new_str = TMALLOC(char, strlen(curr_ptr) + strlen(params[i]) + 1); sprintf( new_str, "%s%s", curr_ptr, params[i] ); } } @@ -2578,7 +2578,7 @@ inp_do_macro_param_replace( int fcn_number, char *params[] ) if ( curr_str == NULL ) { curr_str = curr_ptr; } else { - new_str = (char*) tmalloc( strlen(curr_str) + strlen(curr_ptr) + 1 ); + new_str = TMALLOC(char, strlen(curr_str) + strlen(curr_ptr) + 1); sprintf( new_str, "%s%s", curr_str, curr_ptr ); tfree(curr_str); curr_str = new_str; @@ -2669,11 +2669,11 @@ inp_expand_macro_in_str( char *str ) keep = *fcn_name; *fcn_name = '\0'; if ( curr_str == NULL ) { - new_str = (char*) tmalloc( strlen(str) + strlen(macro_str) + strlen(close_paren_ptr+1) + 3 ); + new_str = TMALLOC(char, strlen(str) + strlen(macro_str) + strlen(close_paren_ptr + 1) + 3); sprintf( new_str, "%s(%s)", str, macro_str ); curr_str = new_str; } else { - new_str = (char*) tmalloc( strlen(curr_str) + strlen(str) + strlen(macro_str) + strlen(close_paren_ptr+1) + 3 ); + new_str = TMALLOC(char, strlen(curr_str) + strlen(str) + strlen(macro_str) + strlen(close_paren_ptr + 1) + 3); sprintf( new_str, "%s%s(%s)", curr_str, str, macro_str ); tfree(curr_str); curr_str = new_str; @@ -2696,7 +2696,7 @@ inp_expand_macro_in_str( char *str ) } else { if ( str != NULL ) { - new_str = (char*) tmalloc( strlen(curr_str) + strlen(str) + 1 ); + new_str = TMALLOC(char, strlen(curr_str) + strlen(str) + 1); sprintf( new_str, "%s%s", curr_str, str ); tfree(curr_str); curr_str = new_str; @@ -2831,7 +2831,7 @@ inp_fix_param_values( struct line *deck ) end_of_str++; n++; } - vec_str = (char*) tmalloc(n); /* string xx yyy from vector [xx yyy] */ + vec_str = TMALLOC(char, n); /* string xx yyy from vector [xx yyy] */ *vec_str = '\0'; strncat(vec_str, beg_of_str + 1, n - 1); @@ -2842,7 +2842,7 @@ inp_fix_param_values( struct line *deck ) if (!natok) break; wl = alloc(struct wordlist); - buffer = (char*) tmalloc(strlen(natok) + 4); + buffer = TMALLOC(char, strlen(natok) + 4); if ( isdigit(*natok) || *natok == '{' || *natok == '.' || *natok == '"' || ( *natok == '-' && isdigit(*(natok+1)) ) || ciprefix("true", natok) || ciprefix("false", natok) || @@ -2886,7 +2886,7 @@ inp_fix_param_values( struct line *deck ) wl_free(nwl); /* insert new vector into actual line */ *equal_ptr = '\0'; - new_str = (char*) tmalloc( strlen(c->li_line) + strlen(newvec) + strlen(end_of_str+1) + 5 ); + new_str = TMALLOC(char, strlen(c->li_line) + strlen(newvec) + strlen(end_of_str + 1) + 5); sprintf( new_str, "%s=[%s] %s", c->li_line, newvec, end_of_str+1 ); tfree(newvec); @@ -2903,7 +2903,7 @@ inp_fix_param_values( struct line *deck ) end_of_str++; n++; } - vec_str = (char*) tmalloc(n); /* string xx yyy from vector [xx yyy] */ + vec_str = TMALLOC(char, n); /* string xx yyy from vector [xx yyy] */ *vec_str = '\0'; strncat(vec_str, beg_of_str + 1, n - 1); @@ -2914,7 +2914,7 @@ inp_fix_param_values( struct line *deck ) if (!natok) break; wl = alloc(struct wordlist); - buffer = (char*) tmalloc(strlen(natok) + 4); + buffer = TMALLOC(char, strlen(natok) + 4); if ( isdigit(*natok) || *natok == '{' || *natok == '.' || *natok == '"' || ( *natok == '-' && isdigit(*(natok+1)) ) || ciprefix("true", natok) || ciprefix("false", natok)) { @@ -2936,7 +2936,7 @@ inp_fix_param_values( struct line *deck ) wl_free(nwl); /* insert new complex value into actual line */ *equal_ptr = '\0'; - new_str = (char*) tmalloc( strlen(c->li_line) + strlen(newvec) + strlen(end_of_str+1) + 5 ); + new_str = TMALLOC(char, strlen(c->li_line) + strlen(newvec) + strlen(end_of_str + 1) + 5); sprintf( new_str, "%s=<%s> %s", c->li_line, newvec, end_of_str+1 ); tfree(newvec); @@ -2956,13 +2956,13 @@ inp_fix_param_values( struct line *deck ) *equal_ptr = '\0'; if ( *end_of_str == '\0' ) { - new_str = (char*) tmalloc( strlen(c->li_line) + strlen(beg_of_str) + 4 ); + new_str = TMALLOC(char, strlen(c->li_line) + strlen(beg_of_str) + 4); sprintf( new_str, "%s={%s}", c->li_line, beg_of_str ); } else { *end_of_str = '\0'; - new_str = (char*) tmalloc( strlen(c->li_line) + strlen(beg_of_str) + strlen(end_of_str+1) + 5 ); + new_str = TMALLOC(char, strlen(c->li_line) + strlen(beg_of_str) + strlen(end_of_str + 1) + 5); sprintf( new_str, "%s={%s} %s", c->li_line, beg_of_str, end_of_str+1 ); } old_str = c->li_line; @@ -3168,22 +3168,22 @@ inp_sort_params( struct line *start_card, struct line *end_card, struct line *ca num_params = 0; /* This is just to keep the code in row 2907ff. */ // dynamic memory allocation - level = (int *) tmalloc(arr_size*sizeof(int)); - param_skip = (int *) tmalloc(arr_size*sizeof(int)); - param_names = (char **) tmalloc(arr_size*sizeof(char*)); - param_strs = (char **) tmalloc(arr_size*sizeof(char*)); + level = TMALLOC(int, arr_size); + param_skip = TMALLOC(int, arr_size); + param_names = TMALLOC(char *, arr_size); + param_strs = TMALLOC(char *, arr_size); /* array[row][column] -> depends_on[array_size][100] */ /* rows */ - depends_on = (char ***) tmalloc(sizeof(char **) * arr_size); + depends_on = TMALLOC(char **, arr_size); /* columns */ for (i = 0; i < arr_size; i++) { - depends_on[i] = (char **) tmalloc(sizeof(char *) * 100); + depends_on[i] = TMALLOC(char *, 100); } - ptr_array = (struct line **) tmalloc(arr_size*sizeof(struct line *)); - ptr_array_ordered = (struct line **) tmalloc(arr_size*sizeof(struct line *)); + ptr_array = TMALLOC(struct line *, arr_size); + ptr_array_ordered = TMALLOC(struct line *, arr_size); ptr = start_card; while ( ptr != NULL ) @@ -3298,12 +3298,12 @@ inp_sort_params( struct line *start_card, struct line *end_card, struct line *ca *str_ptr = '\0'; if ( *end != '\0' ) { - new_str = (char*) tmalloc( strlen(curr_line) + strlen(param_names[i]) + strlen(end) + 3 ); + new_str = TMALLOC(char, strlen(curr_line) + strlen(param_names[i]) + strlen(end) + 3); sprintf( new_str, "%s{%s}%s", curr_line, param_names[i], end ); } else { - new_str = (char*) tmalloc( strlen(curr_line) + strlen(param_names[i]) + 3 ); + new_str = TMALLOC(char, strlen(curr_line) + strlen(param_names[i]) + 3); sprintf( new_str, "%s{%s}", curr_line, param_names[i] ); } str_ptr = new_str + strlen(curr_line) + strlen(param_names[i]); @@ -3377,7 +3377,7 @@ inp_add_params_to_subckt( struct line *subckt_card ) while ( isspace(*param_ptr) ) param_ptr++; if ( !strstr( subckt_line, "params:" ) ) { - new_line = (char*) tmalloc( strlen(subckt_line) + strlen("params: ") + strlen(param_ptr) + 2 ); + new_line = TMALLOC(char, strlen(subckt_line) + strlen("params: ") + strlen(param_ptr) + 2); sprintf( new_line, "%s params: %s", subckt_line, param_ptr ); subckt_name = subckt_card->li_line; @@ -3390,7 +3390,7 @@ inp_add_params_to_subckt( struct line *subckt_card ) subckt_w_params[num_subckt_w_params++] = strdup(subckt_name); *end_ptr = keep; } else { - new_line = (char*) tmalloc( strlen(subckt_line) + strlen(param_ptr) + 2 ); + new_line = TMALLOC(char, strlen(subckt_line) + strlen(param_ptr) + 2); sprintf( new_line, "%s %s", subckt_line, param_ptr ); } @@ -3515,7 +3515,7 @@ inp_split_multi_param_lines( struct line *deck, int line_num ) beg_param++; keep = *end_param; *end_param = '\0'; - new_line = (char*) tmalloc( strlen(".param ") + strlen(beg_param) + 1 ); + new_line = TMALLOC(char, strlen(".param ") + strlen(beg_param) + 1); sprintf( new_line, ".param %s", beg_param ); array[counter++] = new_line; *end_param = keep; @@ -3674,13 +3674,13 @@ static void inp_compat(struct line *deck) // Exxx n1 n2 int1 0 1 xlen = 2*strlen(title_tok) + strlen(node1) + strlen(node2) + 20 - 4*2 + 1; - ckt_array[0] = (char*)tmalloc(xlen); + ckt_array[0] = TMALLOC(char, xlen); sprintf(ckt_array[0], "%s %s %s %s_int1 0 1", title_tok, node1, node2, title_tok); // BExxx int1 0 V = {equation} xlen = 2*strlen(title_tok) + strlen(str_ptr) + 20 - 3*2 + 1; - ckt_array[1] = (char*)tmalloc(xlen); + ckt_array[1] = TMALLOC(char, xlen); sprintf(ckt_array[1], "b%s %s_int1 0 v = %s", title_tok, title_tok, str_ptr); @@ -3744,13 +3744,13 @@ static void inp_compat(struct line *deck) // Gxxx n1 n2 int1 0 1 xlen = 2*strlen(title_tok) + strlen(node1) + strlen(node2) + 20 - 4*2 + 1; - ckt_array[0] = (char*)tmalloc(xlen); + ckt_array[0] = TMALLOC(char, xlen); sprintf(ckt_array[0], "%s %s %s %s_int1 0 1", title_tok, node1, node2, title_tok); // BGxxx int1 0 V = {equation} xlen = 2*strlen(title_tok) + strlen(str_ptr) + 20 - 3*2 + 1; - ckt_array[1] = (char*)tmalloc(xlen); + ckt_array[1] = TMALLOC(char, xlen); sprintf(ckt_array[1], "b%s %s_int1 0 v = %s", title_tok, title_tok, str_ptr); @@ -3806,7 +3806,7 @@ static void inp_compat(struct line *deck) xlen = strlen(title_tok) + strlen(node1) + strlen(node2) + strlen(node1) + strlen(node2) + strlen(str_ptr) + 28 - 6*2 + 1; - xline = (char*)tmalloc(xlen); + xline = TMALLOC(char, xlen); sprintf(xline, "b%s %s %s i = v(%s, %s)/(%s)", title_tok, node1, node2, node1, node2, str_ptr); new_line = alloc(struct line); @@ -3847,18 +3847,18 @@ static void inp_compat(struct line *deck) // Exxx n-aux 0 n1 n2 1 xlen = 2*strlen(title_tok) + strlen(node1) + strlen(node2) + 21 - 4*2 + 1; - ckt_array[0] = (char*)tmalloc(xlen); + ckt_array[0] = TMALLOC(char, xlen); sprintf(ckt_array[0], "e%s %s_int2 0 %s %s 1", title_tok, title_tok, node1, node2); // Cxxx n-aux 0 1 xlen = 2*strlen(title_tok) + 15 - 2*2 + 1; - ckt_array[1] = (char*)tmalloc(xlen); + ckt_array[1] = TMALLOC(char, xlen); sprintf(ckt_array[1], "c%s %s_int2 0 1", title_tok, title_tok); // Bxxx n2 n1 I = i(Exxx) * equation xlen = 2*strlen(title_tok) + strlen(node2) + strlen(node1) + strlen(str_ptr) + 27 - 2*5 + 1; - ckt_array[2] = (char*)tmalloc(xlen); + ckt_array[2] = TMALLOC(char, xlen); sprintf(ckt_array[2], "b%s %s %s i = i(e%s) * (%s)", title_tok, node2, node1, title_tok, str_ptr); @@ -3916,18 +3916,18 @@ static void inp_compat(struct line *deck) // Fxxx n-aux 0 Bxxx 1 xlen = 3*strlen(title_tok) + 20 - 3*2 + 1; - ckt_array[0] = (char*)tmalloc(xlen); + ckt_array[0] = TMALLOC(char, xlen); sprintf(ckt_array[0], "f%s %s_int2 0 b%s -1", title_tok, title_tok, title_tok); // Lxxx n-aux 0 1 xlen = 2*strlen(title_tok) + 15 - 2*2 + 1; - ckt_array[1] = (char*)tmalloc(xlen); + ckt_array[1] = TMALLOC(char, xlen); sprintf(ckt_array[1], "l%s %s_int2 0 1", title_tok, title_tok); // Bxxx n1 n2 V = v(n-aux) * equation xlen = 2*strlen(title_tok) + strlen(node2) + strlen(node1) + strlen(str_ptr) + 31 - 2*5 + 1; - ckt_array[2] = (char*)tmalloc(xlen); + ckt_array[2] = TMALLOC(char, xlen); sprintf(ckt_array[2], "b%s %s %s v = v(%s_int2) * (%s)", title_tok, node1, node2, title_tok, str_ptr); @@ -4033,17 +4033,17 @@ static void inp_compat(struct line *deck) exp_ptr = copy_substring(beg_ptr, end_ptr-2); cut_line = str_ptr; // generate node - out_ptr = (char*)tmalloc(6); + out_ptr = TMALLOC(char, 6); sprintf(out_ptr, "pa_%02d", pai); // Bout_ptr out_ptr 0 V = v(expr_ptr) xlen = 2*strlen(out_ptr) + strlen(exp_ptr )+ 15 - 2*3 + 1; - ckt_array[pai] = (char*)tmalloc(xlen); + ckt_array[pai] = TMALLOC(char, xlen); sprintf(ckt_array[pai], "b%s %s 0 v = %s", out_ptr, out_ptr, exp_ptr); ckt_array[++pai] = NULL; // length of the replacement V(out_ptr) xlen = strlen(out_ptr) + 4; - del_ptr = copy_ptr = (char*)tmalloc(xlen); + del_ptr = copy_ptr = TMALLOC(char, xlen); sprintf(copy_ptr, "v(%s)", out_ptr); // length of the replacement part in original line xlen = strlen(exp_ptr) + 7; @@ -4064,17 +4064,17 @@ static void inp_compat(struct line *deck) end_ptr++; exp_ptr = copy_substring(beg_ptr, end_ptr-3); // generate node - out_ptr = (char*)tmalloc(6); + out_ptr = TMALLOC(char, 6); sprintf(out_ptr, "pa_%02d", pai); // Bout_ptr out_ptr 0 V = v(expr_ptr) xlen = 2*strlen(out_ptr) + strlen(exp_ptr )+ 15 - 2*3 + 1; - ckt_array[pai] = (char*)tmalloc(xlen); + ckt_array[pai] = TMALLOC(char, xlen); sprintf(ckt_array[pai], "b%s %s 0 v = %s", out_ptr, out_ptr, exp_ptr); ckt_array[++pai] = NULL; // length of the replacement V(out_ptr) xlen = strlen(out_ptr) + 4; - del_ptr = copy_ptr = (char*)tmalloc(xlen); + del_ptr = copy_ptr = TMALLOC(char, xlen); sprintf(copy_ptr, "v(%s)", out_ptr); // length of the replacement part in original line xlen = strlen(exp_ptr) + 9; @@ -4150,17 +4150,17 @@ static void inp_compat(struct line *deck) exp_ptr = copy_substring(beg_ptr, end_ptr-2); cut_line = str_ptr; // generate node - out_ptr = (char*)tmalloc(6); + out_ptr = TMALLOC(char, 6); sprintf(out_ptr, "pa_%02d", pai); // Bout_ptr out_ptr 0 V = v(expr_ptr) xlen = 2*strlen(out_ptr) + strlen(exp_ptr )+ 15 - 2*3 + 1; - ckt_array[pai] = (char*)tmalloc(xlen); + ckt_array[pai] = TMALLOC(char, xlen); sprintf(ckt_array[pai], "b%s %s 0 v = %s", out_ptr, out_ptr, exp_ptr); ckt_array[++pai] = NULL; // length of the replacement V(out_ptr) xlen = strlen(out_ptr) + 1; - del_ptr = copy_ptr = (char*)tmalloc(xlen); + del_ptr = copy_ptr = TMALLOC(char, xlen); sprintf(copy_ptr, "%s", out_ptr); // length of the replacement part in original line xlen = strlen(exp_ptr) + 7; @@ -4189,13 +4189,13 @@ static void inp_compat(struct line *deck) exp_ptr = copy_substring(beg_ptr, end_ptr-3); // Bout_ptr out_ptr 0 V = v(expr_ptr) xlen = 2*strlen(out_ptr) + strlen(exp_ptr )+ 15 - 2*3 + 1; - ckt_array[pai] = (char*)tmalloc(xlen); + ckt_array[pai] = TMALLOC(char, xlen); sprintf(ckt_array[pai], "b%s %s 0 v = %s", out_ptr, out_ptr, exp_ptr); ckt_array[++pai] = NULL; // length of the replacement V(out_ptr) xlen = strlen(out_ptr) + 1; - del_ptr = copy_ptr = (char*)tmalloc(xlen); + del_ptr = copy_ptr = TMALLOC(char, xlen); sprintf(copy_ptr, "%s", out_ptr); // length of the replacement part in original line xlen = strlen(out_ptr) + strlen(exp_ptr) + 10; @@ -4464,7 +4464,7 @@ static void inp_bsource_compat(struct line *deck) /* {} around all other tokens */ else { xlen = strlen(buf); - tmp_char = (char*) tmalloc(xlen + 3); + tmp_char = TMALLOC(char, xlen + 3); sprintf(tmp_char, "{%s}", buf); cwl->wl_word = tmp_char; } @@ -4475,7 +4475,7 @@ static void inp_bsource_compat(struct line *deck) { /* allow 100p, 5MEG etc. */ dvalue = INPevaluate(&str_ptr, &error1, 2); - cvalue = (char*) tmalloc(19); + cvalue = TMALLOC(char, 19); sprintf(cvalue,"%18.10e", dvalue); /* unary -, change sign */ if (ustate == 2) { @@ -4510,7 +4510,7 @@ static void inp_bsource_compat(struct line *deck) /* cut the tmp_char after the equal sign */ *(equal_ptr + 1) = '\0'; xlen = strlen(tmp_char) + strlen(new_str) + 2; - final_str = (char*) tmalloc(xlen); + final_str = TMALLOC(char, xlen); sprintf(final_str, "%s %s", tmp_char, new_str); new_line = alloc(struct line); diff --git a/src/frontend/interp.c b/src/frontend/interp.c index d24177ae4..80890cd27 100644 --- a/src/frontend/interp.c +++ b/src/frontend/interp.c @@ -35,7 +35,7 @@ lincopy(struct dvec *ov, double *newscale, int newlen, struct dvec *oldscale) v->v_flags |= VF_PERMANENT; v->v_length = newlen; - nd = (double *) tmalloc(newlen * sizeof (double)); + nd = TMALLOC(double, newlen); if (!ft_interpolate(ov->v_realdata, nd, oldscale->v_realdata, oldscale->v_length, newscale, newlen, 1)) { fprintf(cp_err, "Error: can't interpolate %s\n", ov->v_name); diff --git a/src/frontend/linear.c b/src/frontend/linear.c index b71f52c81..4c6ead78a 100644 --- a/src/frontend/linear.c +++ b/src/frontend/linear.c @@ -72,7 +72,7 @@ com_linearize(wordlist *wl) newtime->v_flags |= VF_PERMANENT; newtime->v_length = len; newtime->v_plot = new; - newtime->v_realdata = (double *) tmalloc(len * sizeof (double)); + newtime->v_realdata = TMALLOC(double, len); for (i = 0, d = tstart; i < len; i++, d += tstep) newtime->v_realdata[i] = d; new->pl_scale = new->pl_dvecs = newtime; diff --git a/src/frontend/measure.c b/src/frontend/measure.c index 5cf722097..debe462d6 100644 --- a/src/frontend/measure.c +++ b/src/frontend/measure.c @@ -418,7 +418,7 @@ static wordlist *measure_parse_line( char *line ) break ; } len += strlen( extra_item ) + 2 ; - long_str = (char*) MALLOC(len) ; + long_str = TMALLOC(char, len) ; sprintf( long_str, "%s%s", item, extra_item ) ; txfree( item ) ; txfree( extra_item ) ; diff --git a/src/frontend/numparam/spicenum.c b/src/frontend/numparam/spicenum.c index e3cad0252..cc605cc2b 100644 --- a/src/frontend/numparam/spicenum.c +++ b/src/frontend/numparam/spicenum.c @@ -455,8 +455,8 @@ nupa_init (char *srcfile) dicoS = (tdico *)new(sizeof(tdico)); initdico (dicoS); - dicoS->dynrefptr = (char**)tmalloc((dynmaxline + 1)*sizeof(char*)); - dicoS->dyncategory = (char*)tmalloc((dynmaxline + 1)*sizeof(char)); + dicoS->dynrefptr = TMALLOC(char*, dynmaxline + 1); + dicoS->dyncategory = TMALLOC(char, dynmaxline + 1); for (i = 0; i <= dynmaxline; i++) { diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index 4093c236f..151dcaafe 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -194,8 +194,8 @@ initdico (tdico * dico) dico->stack_depth = 0 ; /* top of the stack */ asize = dico->symbol_stack_alloc = 10 ;/* expected stack depth - no longer limited */ asize++ ; /* account for zero */ - dico->local_symbols = (NGHASHPTR*) tmalloc( asize * sizeof(NGHASHPTR) ) ; - dico->inst_name = (char**) tmalloc( asize * sizeof(char *) ) ; + dico->local_symbols = TMALLOC(NGHASHPTR, asize) ; + dico->inst_name = TMALLOC(char*, asize) ; dico->inst_symbols = NULL ; /* instance qualified are lazily allocated */ initkeys (); @@ -245,8 +245,8 @@ dicostack (tdico * dico, char op) /* Just double the stack alloc */ dico->symbol_stack_alloc *= 2 ; asize = dico->symbol_stack_alloc + 1 ; /* account for zero */ - dico->local_symbols = (NGHASHPTR*) trealloc( dico->local_symbols, asize * sizeof(NGHASHPTR) ) ; - dico->inst_name = (char**) trealloc( dico->inst_name, asize * sizeof(char *) ) ; + dico->local_symbols = TREALLOC(NGHASHPTR, dico->local_symbols, asize) ; + dico->inst_name = TREALLOC(char*, dico->inst_name, asize) ; } /* lazy allocation - don't allocate space if we can help it */ dico->local_symbols[dico->stack_depth] = NULL ; @@ -400,7 +400,7 @@ attrib (tdico *dico_p, NGHASHPTR htable_p, char *t, char op) if (!(entry_p)) { - entry_p = (entry*) tmalloc( sizeof(entry) ) ; + entry_p = TMALLOC(entry, 1) ; entry_p->symbol = strdup( t ) ; entry_p->tp = '?'; /* signal Unknown */ entry_p->level = dico_p->stack_depth ; diff --git a/src/frontend/options.c b/src/frontend/options.c index 4c815c2ff..96cffe3b7 100644 --- a/src/frontend/options.c +++ b/src/frontend/options.c @@ -214,13 +214,13 @@ inp_getoptsc(char *in_line, struct line *com_options) struct line *next = NULL; char* line; - line = (char*)tmalloc(strlen(in_line) + 3); + line = TMALLOC(char, strlen(in_line) + 3); /* option -> .options */ /* skip option */ gettok(&in_line); sprintf(line, ".options %s", in_line); - next = (struct line*)tmalloc(sizeof(struct line)); + next = TMALLOC(struct line, 1); next->li_line = line; next->li_linenum = 0; next->li_error = NULL; diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index ef18a8319..c05df19f8 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -169,7 +169,7 @@ beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analNam */ numsaves = ft_getSaves(&saves); if (numsaves) { - savesused = (bool *) tmalloc(sizeof (bool) * numsaves); + savesused = TMALLOC(bool, numsaves); saveall = FALSE; for (i = 0; i < numsaves; i++) { if (saves[i].analysis && !cieq((char *)saves[i].analysis, an_name)) { @@ -382,10 +382,9 @@ addDataDesc(runDesc *run, char *name, int type, int ind) dataDesc *data; if (!run->numData) - run->data = (dataDesc *) tmalloc(sizeof (dataDesc)); + run->data = TMALLOC(dataDesc, 1); else - run->data = (dataDesc *) trealloc((char *) run->data, - sizeof (dataDesc) * (run->numData + 1)); + run->data = TREALLOC(dataDesc, run->data, run->numData + 1); data = &run->data[run->numData]; /* so freeRun will get nice NULL pointers for the fields we don't set */ bzero(data, sizeof(dataDesc)); @@ -413,10 +412,9 @@ addSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind) char *unique; /* unique char * from back-end */ if (!run->numData) - run->data = (dataDesc *) tmalloc(sizeof (dataDesc)); + run->data = TMALLOC(dataDesc, 1); else - run->data = (dataDesc *) trealloc((char *) run->data, - sizeof (dataDesc) * (run->numData + 1)); + run->data = TREALLOC(dataDesc, run->data, run->numData + 1); data = &run->data[run->numData]; /* so freeRun will get nice NULL pointers for the fields we don't set */ bzero(data, sizeof(dataDesc)); @@ -979,12 +977,12 @@ plotAddRealValue(dataDesc *desc, double value) struct dvec *v = desc->vec; if (isreal(v)) { - v->v_realdata = (double *) newrealloc((char *) v->v_realdata, + v->v_realdata = (double *) newrealloc(v->v_realdata, sizeof (double) * (v->v_length + 1)); v->v_realdata[v->v_length] = value; } else { /* a real parading as a VF_COMPLEX */ - v->v_compdata = (ngcomplex_t *) newrealloc((char *) v->v_compdata, + v->v_compdata = (ngcomplex_t *) newrealloc(v->v_compdata, sizeof(ngcomplex_t) * (v->v_length + 1)); v->v_compdata[v->v_length].cx_real = value; v->v_compdata[v->v_length].cx_imag = (double) 0; @@ -1000,7 +998,7 @@ plotAddComplexValue(dataDesc *desc, IFcomplex value) { struct dvec *v = desc->vec; - v->v_compdata = (ngcomplex_t *) newrealloc((char *) v->v_compdata, + v->v_compdata = (ngcomplex_t *) newrealloc(v->v_compdata, sizeof(ngcomplex_t) * (v->v_length + 1)); v->v_compdata[v->v_length].cx_real = value.real; v->v_compdata[v->v_length].cx_imag = value.imag; diff --git a/src/frontend/parse.c b/src/frontend/parse.c index b08f45fed..b36ddb9be 100644 --- a/src/frontend/parse.c +++ b/src/frontend/parse.c @@ -340,7 +340,7 @@ mknnode(double number) v->v_name = copy(buf); v->v_type = SV_NOTYPE; v->v_flags = VF_REAL; - v->v_realdata = (double *) tmalloc(sizeof (double)); + v->v_realdata = TMALLOC(double, 1); *v->v_realdata = number; v->v_length = 1; v->v_plot = NULL; diff --git a/src/frontend/parser/complete.c b/src/frontend/parser/complete.c index 3674c7a82..c71c11590 100644 --- a/src/frontend/parser/complete.c +++ b/src/frontend/parser/complete.c @@ -627,7 +627,7 @@ clookup(register char *word, struct ccom **dd, bool pref, bool create) place->cc_sibling->cc_ysibling = place; place->cc_sibling->cc_parent = place->cc_parent; place = place->cc_sibling; - place->cc_name = (char*) tmalloc(ind + 2); + place->cc_name = TMALLOC(char, ind + 2); for (i = 0; i < ind + 1; i++) place->cc_name[i] = word[i]; place->cc_name[ind + 1] = '\0'; @@ -651,7 +651,7 @@ clookup(register char *word, struct ccom **dd, bool pref, bool create) tmpc->cc_parent->cc_child = tmpc; else *dd = place; - place->cc_name = (char*) tmalloc(ind + 2); + place->cc_name = TMALLOC(char, ind + 2); for (i = 0; i < ind + 1; i++) place->cc_name[i] = word[i]; place->cc_name[ind + 1] = '\0'; @@ -673,7 +673,7 @@ clookup(register char *word, struct ccom **dd, bool pref, bool create) tmpc->cc_parent = place; place->cc_child = tmpc; place = tmpc; - place->cc_name = (char*) tmalloc(ind + 3); + place->cc_name = TMALLOC(char, ind + 3); for (i = 0; i < ind + 2; i++) place->cc_name[i] = word[i]; place->cc_name[ind + 2] = '\0'; diff --git a/src/frontend/parser/glob.c b/src/frontend/parser/glob.c index 0b4da387c..6922e7876 100644 --- a/src/frontend/parser/glob.c +++ b/src/frontend/parser/glob.c @@ -116,7 +116,7 @@ brac1(char *string) int nb; words = alloc(struct wordlist); - words->wl_word = (char*) tmalloc(BSIZE_SP); + words->wl_word = TMALLOC(char, BSIZE_SP); words->wl_word[0] = 0; words->wl_next = NULL; words->wl_prev = NULL; @@ -144,7 +144,7 @@ brac1(char *string) nw = alloc(struct wordlist); nw->wl_next = NULL; nw->wl_prev = NULL; - nw->wl_word = (char*) tmalloc(BSIZE_SP); + nw->wl_word = TMALLOC(char, BSIZE_SP); (void) strcpy(nw->wl_word, wl->wl_word); (void) strcat(nw->wl_word, w->wl_word); newwl = wl_append(newwl, nw); diff --git a/src/frontend/plotting/agraf.c b/src/frontend/plotting/agraf.c index f1fd10823..2e22538e2 100644 --- a/src/frontend/plotting/agraf.c +++ b/src/frontend/plotting/agraf.c @@ -95,11 +95,11 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s v->v_linestyle = (PCHARS[i] ? PCHARS[i++] : '#'); } /* Now allocate the field and stuff. */ - field = (char*) tmalloc((maxy + 1) * (maxx + 1)); - line1 = (char*) tmalloc(maxy + margin + FUDGE + 1); - line2 = (char*) tmalloc(maxy + margin + FUDGE + 1); + field = TMALLOC(char, (maxy + 1) * (maxx + 1)); + line1 = TMALLOC(char, maxy + margin + FUDGE + 1); + line2 = TMALLOC(char, maxy + margin + FUDGE + 1); if (!novalue) - values = (double *) tmalloc(maxx * sizeof (double)); + values = TMALLOC(double, maxx); /* Clear the field, put the lines in the right places, and create * the headers. diff --git a/src/frontend/plotting/graf.c b/src/frontend/plotting/graf.c index cd6316928..26e0f6992 100644 --- a/src/frontend/plotting/graf.c +++ b/src/frontend/plotting/graf.c @@ -136,7 +136,7 @@ gr_init(double *xlims, double *ylims, /* The size of the screen. */ pname = "(unknown)"; if (!plotname) plotname = "(unknown)"; - comb_title = (char*) tmalloc(strlen(plotname) + strlen(pname) + 3); + comb_title = TMALLOC(char, strlen(plotname) + strlen(pname) + 3); sprintf(comb_title, "%s: %s", pname, plotname); graph->plotname = comb_title; #endif @@ -191,7 +191,7 @@ gr_init(double *xlims, double *ylims, /* The size of the screen. */ pname = "(unknown)"; if (!plotname) plotname = "(unknown)"; - comb_title = (char*) tmalloc(strlen(plotname) + strlen(pname) + 3); + comb_title = TMALLOC(char, strlen(plotname) + strlen(pname) + 3); sprintf(comb_title, "%s: %s", pname, plotname); graph->plotname = comb_title; #endif @@ -359,7 +359,7 @@ gr_start_internal(struct dvec *dv, bool copyvec) dv->v_color = curcolor; /* save the data so we can refresh */ - link = (struct dveclist *) tmalloc(sizeof(struct dveclist)); + link = TMALLOC(struct dveclist, 1); link->next = currentgraph->plotdata; if (copyvec) { @@ -1043,7 +1043,7 @@ readtics(char *string) char *words, *worde; double *tics, *ticsk; - tics = (double *) tmalloc(MAXTICS * sizeof(double)); + tics = TMALLOC(double, MAXTICS); ticsk = tics; words = string; diff --git a/src/frontend/plotting/graphdb.c b/src/frontend/plotting/graphdb.c index 9e3ac8a74..3a655ffce 100644 --- a/src/frontend/plotting/graphdb.c +++ b/src/frontend/plotting/graphdb.c @@ -34,7 +34,7 @@ typedef struct listgraph { GRAPH graph; struct listgraph *next; } LISTGRAPH; -#define NEWLISTGRAPH (LISTGRAPH *) tmalloc(sizeof(LISTGRAPH)) +#define NEWLISTGRAPH TMALLOC(LISTGRAPH, 1) #define NUMGBUCKETS 16 @@ -122,7 +122,7 @@ GRAPH *CopyGraph(GRAPH *graph) /* copy dvecs */ ret->plotdata = NULL; for (link = graph->plotdata; link; link = link->next) { - newlink = (struct dveclist *) tmalloc(sizeof(struct dveclist)); + newlink = TMALLOC(struct dveclist, 1); newlink->next = ret->plotdata; newlink->vector = vec_copy(link->vector); /* vec_copy doesn't set v_color or v_linestyle */ @@ -246,7 +246,7 @@ typedef struct gcstack { struct gcstack *next; } GCSTACK; GCSTACK *gcstacktop; -#define NEWGCSTACK (GCSTACK *) tmalloc(sizeof(GCSTACK)) +#define NEWGCSTACK TMALLOC(GCSTACK, 1) /* note: This Push and Pop has tricky semantics. Push(graph) will push the currentgraph onto the stack diff --git a/src/frontend/plotting/plotcurv.c b/src/frontend/plotting/plotcurv.c index 6b554f202..465b3e89b 100644 --- a/src/frontend/plotting/plotcurv.c +++ b/src/frontend/plotting/plotcurv.c @@ -158,21 +158,19 @@ ft_graf(struct dvec *v, struct dvec *xs, bool nostart) if (gridsize) { /* This is done quite differently from what we do below... */ - gridbuf = (double *) tmalloc(gridsize * sizeof (double)); - result = (double *) tmalloc(gridsize * sizeof (double)); + gridbuf = TMALLOC(double, gridsize); + result = TMALLOC(double, gridsize); if (isreal(v)) ydata = v->v_realdata; else { - ydata = (double *) tmalloc(v->v_length * - sizeof (double)); + ydata = TMALLOC(double, v->v_length); for (i = 0; i < v->v_length; i++) ydata[i] = realpart(&v->v_compdata[i]); } if (isreal(xs)) xdata = xs->v_realdata; else { - xdata = (double *) tmalloc(xs->v_length * - sizeof (double)); + xdata = TMALLOC(double, xs->v_length); for (i = 0; i < xs->v_length; i++) xdata[i] = realpart(&xs->v_compdata[i]); } @@ -211,11 +209,10 @@ ft_graf(struct dvec *v, struct dvec *xs, bool nostart) /* We need to do curve fitting now. First get some scratch * space */ - scratch = (double *) tmalloc(((degree + 1) * (degree + 2)) * - sizeof (double)); - result = (double *) tmalloc((degree + 1) * sizeof (double)); - xdata = (double *) tmalloc((degree + 1) * sizeof (double)); - ydata = (double *) tmalloc((degree + 1) * sizeof (double)); + scratch = TMALLOC(double, (degree + 1) * (degree + 2)); + result = TMALLOC(double, degree + 1); + xdata = TMALLOC(double, degree + 1); + ydata = TMALLOC(double, degree + 1); /* Plot the first degree segments... */ diff --git a/src/frontend/plotting/plotit.c b/src/frontend/plotting/plotit.c index 7b74b1db9..81f381ef9 100644 --- a/src/frontend/plotting/plotit.c +++ b/src/frontend/plotting/plotit.c @@ -45,8 +45,7 @@ getlims(wordlist *wl, char *name, int number) } wk = beg; if (number) { - d = (double *) tmalloc(sizeof (double) * - number); + d = TMALLOC(double, number); for (n = 0; n < number; n++) { wk = wk->wl_next; if (!wk) { @@ -101,7 +100,7 @@ xtend(struct dvec *v, int length) } if (isreal(v)) { od = v->v_realdata; - v->v_realdata = (double *) tmalloc(length * sizeof (double)); + v->v_realdata = TMALLOC(double, length); for (i = 0; i < v->v_length; i++) v->v_realdata[i] = od[i]; d = od[--i]; @@ -110,7 +109,7 @@ xtend(struct dvec *v, int length) tfree(od); } else { oc = v->v_compdata; - v->v_compdata = (ngcomplex_t *) tmalloc(length * sizeof(ngcomplex_t)); + v->v_compdata = TMALLOC(ngcomplex_t, length); for (i = 0; i < v->v_length; i++) { realpart(&v->v_compdata[i]) = realpart(&oc[i]); imagpart(&v->v_compdata[i]) = imagpart(&oc[i]); @@ -940,7 +939,7 @@ plotit(wordlist *wl, char *hcopy, char *devname) newlen = (tstop - tstart) / tstep + 1.5; - newscale = (double *) tmalloc(newlen * sizeof(double)); + newscale = TMALLOC(double, newlen); newv_scale = alloc(struct dvec); newv_scale->v_flags = vecs->v_scale->v_flags; @@ -954,7 +953,7 @@ plotit(wordlist *wl, char *hcopy, char *devname) newscale[i] = ttime; for (v = vecs; v; v= v->v_link2) { - newdata = (double *) tmalloc(newlen * sizeof (double)); + newdata = TMALLOC(double, newlen); if (!ft_interpolate(v->v_realdata, newdata, v->v_scale->v_realdata, v->v_scale->v_length, diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index ba6571fce..93b896795 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -366,7 +366,7 @@ X11_NewViewport(GRAPH *graph) }; int trys; - graph->devdep = (X11devdep*) tmalloc(sizeof(X11devdep)); + graph->devdep = TMALLOC(X11devdep, 1); /* set up new shell */ DEVDEP(graph).shell = XtCreateApplicationShell("shell", diff --git a/src/frontend/postcoms.c b/src/frontend/postcoms.c index d4535e7c7..4911bfcc2 100644 --- a/src/frontend/postcoms.c +++ b/src/frontend/postcoms.c @@ -745,9 +745,9 @@ com_cross(wordlist *wl) v->v_flags |= VF_PERMANENT; v->v_flags = comp ? VF_COMPLEX : VF_REAL; if (comp) - v->v_compdata = (ngcomplex_t *) tmalloc(i * sizeof(ngcomplex_t)); + v->v_compdata = TMALLOC(ngcomplex_t, i); else - v->v_realdata = (double *) tmalloc(i * sizeof (double)); + v->v_realdata = TMALLOC(double, i); /* Now copy the ind'ths elements into this one. */ for (n = vecs, i = 0; n; n = n->v_link2, i++) diff --git a/src/frontend/postsc.c b/src/frontend/postsc.c index 7a5bb1527..3daeec9d4 100644 --- a/src/frontend/postsc.c +++ b/src/frontend/postsc.c @@ -218,7 +218,7 @@ PS_NewViewport(GRAPH *graph) fprintf(plotfile, "/%s findfont %d scalefont setfont\n\n", psfont, (int) (fontsize * scale)); - graph->devdep = (PSdevdep*) tmalloc(sizeof(PSdevdep)); + graph->devdep = TMALLOC(PSdevdep, 1); DEVDEP(graph).lastlinestyle = -1; DEVDEP(graph).lastcolor = -1; DEVDEP(graph).lastx = -1; diff --git a/src/frontend/quote.c b/src/frontend/quote.c index b81a501a9..1f9c8e406 100644 --- a/src/frontend/quote.c +++ b/src/frontend/quote.c @@ -79,7 +79,7 @@ cp_unquote(char *string) int l; if (string) { l = strlen(string); - s = (char*) MALLOC(l+1); + s = TMALLOC(char, l + 1); if (l>=2 && *string == '"' && string[l-1] == '"') { strncpy(s,string+1,l-2); diff --git a/src/frontend/rawfile.c b/src/frontend/rawfile.c index cdd491679..7072f4061 100644 --- a/src/frontend/rawfile.c +++ b/src/frontend/rawfile.c @@ -568,11 +568,9 @@ raw_read(char *name) * be dangerous if the file is invalid. */ if (isreal(v)) - v->v_realdata = (double *) tmalloc( - npoints * sizeof (double)); + v->v_realdata = TMALLOC(double, npoints); else - v->v_compdata = (ngcomplex_t *) tmalloc( - npoints * sizeof(ngcomplex_t)); + v->v_compdata = TMALLOC(ngcomplex_t, npoints); } } else if (ciprefix("values:", buf) || ciprefix("binary:", buf)) { diff --git a/src/frontend/spec.c b/src/frontend/spec.c index 441e81f88..7a662b6d6 100644 --- a/src/frontend/spec.c +++ b/src/frontend/spec.c @@ -81,7 +81,7 @@ com_spec(wordlist *wl) 1/(time[tlen-1] - time[0])); return; } - win = (double *) tmalloc(tlen * sizeof (double)); + win = TMALLOC(double, tlen); { char window[BSIZE_SP]; double maxt = time[tlen-1]; @@ -203,7 +203,7 @@ com_spec(wordlist *wl) plot_cur->pl_name = copy("Spectrum"); plot_cur->pl_date = copy(datestring( )); - freq = (double *) tmalloc(fpts * sizeof(double)); + freq = TMALLOC(double, fpts); f = alloc(struct dvec); ZERO(f, struct dvec); f->v_name = copy("frequency"); @@ -213,11 +213,11 @@ com_spec(wordlist *wl) f->v_realdata = freq; vec_new(f); - tdvec = (double **) tmalloc(ngood * sizeof(double *)); - fdvec = (ngcomplex_t **) tmalloc(ngood * sizeof(ngcomplex_t *)); + tdvec = TMALLOC(double *, ngood); + fdvec = TMALLOC(ngcomplex_t *, ngood); for (i = 0, vec = vlist; iv_realdata; - fdvec[i] = (ngcomplex_t *) tmalloc(fpts * sizeof(ngcomplex_t)); + fdvec[i] = TMALLOC(ngcomplex_t, fpts); f = alloc(struct dvec); ZERO(f, struct dvec); f->v_name = vec_basename(vec); @@ -229,7 +229,7 @@ com_spec(wordlist *wl) vec = vec->v_link2; } - dc = (double *) tmalloc(ngood * sizeof(double)); + dc = TMALLOC(double, ngood); for (i = 0; ibuffer = (char*) tmalloc(bxx_chunksize); + t->buffer = TMALLOC(char, bxx_chunksize); t->dst = t->buffer; t->limit = t->buffer + bxx_chunksize; @@ -788,7 +788,7 @@ bxx_extend(struct bxx_buffer *t, int howmuch) len += howmuch; - t->buffer = (char*) trealloc(t->buffer, len*sizeof(char)); + t->buffer = TREALLOC(char, t->buffer, len); t->dst = t->buffer + pos; t->limit = t->buffer + len; @@ -913,10 +913,10 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub t = gettrans(name, NULL); if (t) { - new_str = (char*) tmalloc( strlen(s) + strlen(t) + strlen(paren_ptr+1) + 3 ); + new_str = TMALLOC(char, strlen(s) + strlen(t) + strlen(paren_ptr + 1) + 3); sprintf( new_str, "%s(%s)%s", s, t, paren_ptr+1 ); } else { - new_str = (char*) tmalloc( strlen(s) + strlen(scname) + strlen(name) + strlen(paren_ptr+1) + 4 ); + new_str = TMALLOC(char, strlen(s) + strlen(scname) + strlen(name) + strlen(paren_ptr + 1) + 4); sprintf( new_str, "%s(%s.%s)%s", s, scname, name, paren_ptr+1 ); } @@ -1644,8 +1644,7 @@ modtranslate(struct line *deck, char *subname) #endif name = gettok(&t); /* at this point, name = .model */ - buffer = (char*) tmalloc(strlen(name) + strlen(t) + - strlen(subname) + 4); + buffer = TMALLOC(char, strlen(name) + strlen(t) + strlen(subname) + 4); (void) sprintf(buffer, "%s ",name); /* at this point, buffer = ".model " */ tfree(name); name = gettok(&t); /* name now holds model name */ @@ -1724,7 +1723,7 @@ devmodtranslate(struct line *deck, char *subname) t++; c = isupper(*t) ? tolower(*t) : *t; /* set c to first char in line. . . . */ found = FALSE; - buffer = (char*) tmalloc(strlen(t) + strlen(subname) + 4); + buffer = TMALLOC(char, strlen(t) + strlen(subname) + 4); switch (c) { diff --git a/src/frontend/variable.c b/src/frontend/variable.c index f5ad8f0b5..dab947549 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -897,7 +897,7 @@ cp_vprint(void) for (v = variables; v; v = v->va_next) i++; - vars = (struct xxx *) tmalloc(sizeof (struct xxx) * i); + vars = TMALLOC(struct xxx, i); out_init(); for (v = variables, i = 0; v; v = v->va_next, i++) { diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index 5deeb476e..f6a1acd6b 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -194,7 +194,7 @@ sortvecs(struct dvec *d) i++; if (i < 2) return (d); - array = (struct dvec **) tmalloc(i * sizeof (struct dvec *)); + array = TMALLOC(struct dvec *, i); for (t = d, i = 0; t; t = t->v_link2) array[i++] = t; @@ -468,7 +468,7 @@ vec_get(const char *vec_name) d->v_name = copy(whole); /* MW. The same as word before */ d->v_type = SV_NOTYPE; d->v_flags |= VF_REAL; /* No complex values yet... */ - d->v_realdata = (double *) tmalloc(sizeof (double)); + d->v_realdata = TMALLOC(double, 1); d->v_length = 1; /* In case the represented variable is a REAL vector this takes @@ -517,13 +517,13 @@ vec_get(const char *vec_name) */ struct variable *nv; double *list; - list = (double *)MALLOC(sizeof(double)); + list = TMALLOC(double, 1); nv = alloc(struct variable); nv = vv->va_vlist; for(i=1; ;i++) { - list=(double *)REALLOC((char *)list,i*sizeof(double)); + list=TREALLOC(double, list, i); *(list+i-1) = nv->va_real; nv = nv->va_next; if (nv==NULL) break; @@ -643,15 +643,13 @@ vec_copy(struct dvec *v) nv->v_flags = v->v_flags & ~VF_PERMANENT; if (isreal(v)) { - nv->v_realdata = (double *) tmalloc(sizeof (double) * - v->v_length); + nv->v_realdata = TMALLOC(double, v->v_length); bcopy(v->v_realdata, nv->v_realdata, sizeof (double) * v->v_length); nv->v_compdata = NULL; } else { nv->v_realdata = NULL; - nv->v_compdata = (ngcomplex_t *) tmalloc(sizeof(ngcomplex_t) * - v->v_length); + nv->v_compdata = TMALLOC(ngcomplex_t, v->v_length); bcopy(v->v_compdata, nv->v_compdata, sizeof(ngcomplex_t) * v->v_length); } @@ -979,7 +977,7 @@ vec_transpose(struct dvec *v) */ if (isreal(v)) { - newreal = (double *) tmalloc(sizeof (double) * v->v_length); + newreal = TMALLOC(double, v->v_length); oldreal = v->v_realdata; koffset = 0; for ( k=0; k < nummatrices; k++ ) { @@ -996,7 +994,7 @@ vec_transpose(struct dvec *v) tfree(oldreal); v->v_realdata = newreal; } else { - newcomp = (ngcomplex_t *) tmalloc(sizeof(ngcomplex_t) * v->v_length); + newcomp = TMALLOC(ngcomplex_t, v->v_length); oldcomp = v->v_compdata; koffset = 0; for ( k=0; k < nummatrices; k++ ) { @@ -1064,10 +1062,10 @@ vec_mkfamily(struct dvec *v) d->v_length = size; if (isreal(v)) { - d->v_realdata = (double *) tmalloc(size * sizeof(double)); + d->v_realdata = TMALLOC(double, size); bcopy(v->v_realdata + size*j, d->v_realdata, size*sizeof(double)); } else { - d->v_compdata = (ngcomplex_t *) tmalloc(size * sizeof(ngcomplex_t)); + d->v_compdata = TMALLOC(ngcomplex_t, size); bcopy(v->v_compdata + size*j, d->v_compdata, size*sizeof(ngcomplex_t)); } /* Add one to the counter. */ diff --git a/src/include/graph.h b/src/include/graph.h index 2a58da89a..09fd01512 100644 --- a/src/include/graph.h +++ b/src/include/graph.h @@ -142,7 +142,7 @@ struct _keyed { }; -#define NEWGRAPH (GRAPH *) tmalloc(sizeof(GRAPH)) +#define NEWGRAPH TMALLOC(GRAPH, 1) #define rnd(x) (int) ((x)+0.5) diff --git a/src/include/hash.h b/src/include/hash.h index 16f0d1e62..8d5c1d647 100644 --- a/src/include/hash.h +++ b/src/include/hash.h @@ -12,8 +12,8 @@ REVISIONS: Aug 21, 2009 - adapted for ngspice #include #define _NGMALLOC(size_xz) tmalloc((size_xz)) -#define NGMALLOC(n, els) (els *) tmalloc((n)*sizeof(els)) -#define NGREALLOC(ar,n,els) (els *) trealloc(ar,(n)*sizeof(els)) +#define NGMALLOC(n, els) TMALLOC(els, n) +#define NGREALLOC(ar,n,els) TREALLOC(els, ar, n) #define NGFREE(els) txfree(els) diff --git a/src/include/macros.h b/src/include/macros.h index c007dfd19..7780cd5c3 100644 --- a/src/include/macros.h +++ b/src/include/macros.h @@ -44,13 +44,13 @@ #define ABORT() fflush(stderr);fflush(stdout);abort(); #define MERROR(CODE,MESSAGE) { \ - errMsg = (char *) tmalloc(strlen(MESSAGE) + 1); \ + errMsg = TMALLOC(char, strlen(MESSAGE) + 1); \ strcpy(errMsg, (MESSAGE)); \ return (CODE); \ } -#define NEW(TYPE) ((TYPE *) tmalloc(sizeof(TYPE))) -#define NEWN(TYPE,COUNT) ((TYPE *) tmalloc(sizeof(TYPE) * (COUNT))) +#define NEW(TYPE) (TMALLOC(TYPE, 1)) +#define NEWN(TYPE,COUNT) (TMALLOC(TYPE, COUNT)) #define R_NORM(A,B) { \ diff --git a/src/include/memory.h b/src/include/memory.h index 578471759..4c22507f0 100644 --- a/src/include/memory.h +++ b/src/include/memory.h @@ -3,6 +3,9 @@ #include +#define TMALLOC(t,n) (t*) /**/ tmalloc(sizeof(t) * (size_t)(n)) +#define TREALLOC(t,p,n) (t*) /**/ trealloc(p, sizeof(t) * (size_t)(n)) + #ifndef HAVE_LIBGC extern void *tmalloc(size_t num); extern void *trealloc(void *str, size_t num); @@ -21,10 +24,10 @@ extern void txfree(void *ptr); #include "../misc/stringutil.h" /* va: spice3 internally bzero */ -#define alloc(TYPE) ((TYPE *) tmalloc(sizeof(TYPE))) +#define alloc(TYPE) (TMALLOC(TYPE, 1)) #define MALLOC(x) tmalloc((unsigned)(x)) #define FREE(x) {if (x) {txfree((char *)(x));(x) = 0;}} -#define REALLOC(x,y) trealloc((char *)(x),(unsigned)(y)) +#define REALLOC(x,y) trealloc((x),(unsigned)(y)) #define ZERO(PTR,TYPE) (bzero((PTR),sizeof(TYPE))) #if defined(_MSC_VER) || defined(__MINGW32__) diff --git a/src/main.c b/src/main.c index 4fdad4d8e..dfa907a7f 100644 --- a/src/main.c +++ b/src/main.c @@ -656,7 +656,7 @@ read_initialisation_file(char * dir, char * name) asprintf(&path, "%s" DIR_PATHSEP "%s", dir,name); if(path==NULL) return FALSE; /* memory allocation error */ #else /* ~ HAVE_ASPRINTF */ - path=(char*)tmalloc(2 + strlen(dir)+strlen(name)); + path = TMALLOC(char, 2 + strlen(dir) + strlen(name)); if(path==NULL) return FALSE; /* memory allocation error */ sprintf(path,"%s" DIR_PATHSEP "%s",dir,name); #endif /* HAVE_ASPRINTF */ diff --git a/src/maths/cmaths/cmath.h b/src/maths/cmaths/cmath.h index 50d0b16a4..4bdbcca1f 100644 --- a/src/maths/cmaths/cmath.h +++ b/src/maths/cmaths/cmath.h @@ -1,7 +1,7 @@ #ifndef _CMATH_H #define _CMATH_H -#define alloc_c(len) ((ngcomplex_t *) tmalloc((len) * sizeof(ngcomplex_t))) -#define alloc_d(len) ((double *) tmalloc((len) * sizeof (double))) +#define alloc_c(len) (TMALLOC(ngcomplex_t, len)) +#define alloc_d(len) (TMALLOC(double, len)) #endif diff --git a/src/maths/ni/niinteg.c b/src/maths/ni/niinteg.c index 9e878133f..9fd15c326 100644 --- a/src/maths/ni/niinteg.c +++ b/src/maths/ni/niinteg.c @@ -35,7 +35,7 @@ NIintegrate(CKTcircuit *ckt, double *geq, double *ceq, double cap, int qcap) ( *(ckt->CKTstate0+qcap) - *(ckt->CKTstate1+qcap) ); break; default: - errMsg = (char*) MALLOC(strlen(ordmsg)+1); + errMsg = TMALLOC(char, strlen(ordmsg) + 1); strcpy(errMsg,ordmsg); return(E_ORDER); } @@ -71,7 +71,7 @@ NIintegrate(CKTcircuit *ckt, double *geq, double *ceq, double cap, int qcap) break; default: - errMsg = (char*) MALLOC(strlen(methodmsg)+1); + errMsg = TMALLOC(char, strlen(methodmsg) + 1); strcpy(errMsg,methodmsg); return(E_METHOD); } diff --git a/src/maths/ni/niiter.c b/src/maths/ni/niiter.c index 44e8c016c..2009f5e3c 100644 --- a/src/maths/ni/niiter.c +++ b/src/maths/ni/niiter.c @@ -70,7 +70,7 @@ NIiter(CKTcircuit *ckt, int maxIter) } } -/* OldCKTstate0=(double *)MALLOC((ckt->CKTnumStates+1)*sizeof(double)); */ +/* OldCKTstate0=TMALLOC(double, ckt->CKTnumStates + 1); */ for(;;){ ckt->CKTnoncon=0; @@ -122,7 +122,7 @@ NIiter(CKTcircuit *ckt, int maxIter) * wrong - so we ask for the troublesome entry */ SMPgetError(ckt->CKTmatrix,&i,&j); - message = (char *)MALLOC(1000); /* should be enough */ + message = TMALLOC(char, 1000); /* should be enough */ (void)sprintf(message, "singular matrix: check nodes %s and %s\n", NODENAME(ckt,i),NODENAME(ckt,j)); @@ -162,7 +162,7 @@ NIiter(CKTcircuit *ckt, int maxIter) /*moved it to here as if xspice is included then CKTload changes CKTnumStates the first time it is run */ if(!OldCKTstate0) - OldCKTstate0=(double *)MALLOC((ckt->CKTnumStates+1)*sizeof(double)); + OldCKTstate0=TMALLOC(double, ckt->CKTnumStates + 1); for(i=0;iCKTnumStates;i++) { *(OldCKTstate0+i) = *(ckt->CKTstate0+i); } @@ -189,7 +189,7 @@ NIiter(CKTcircuit *ckt, int maxIter) /*fprintf(stderr,"too many iterations without convergence: %d iter's (max iter == %d)\n", iterno,maxIter);*/ ckt->CKTstat->STATnumIter += iterno; - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); strcpy(errMsg,msg); #ifdef STEPDEBUG printf("iterlim exceeded \n"); diff --git a/src/maths/ni/nireinit.c b/src/maths/ni/nireinit.c index 58d256144..2a46e2621 100644 --- a/src/maths/ni/nireinit.c +++ b/src/maths/ni/nireinit.c @@ -17,7 +17,7 @@ Author: 1985 Thomas L. Quarles #define CKALLOC(ptr,size,type) if(( ckt->ptr =\ - (type *) MALLOC((size)*sizeof(type))) == NULL) return(E_NOMEM); + TMALLOC(type, size)) == NULL) return(E_NOMEM); int NIreinit( CKTcircuit *ckt) diff --git a/src/maths/ni/nisenre.c b/src/maths/ni/nisenre.c index f0b27044f..02bc75449 100644 --- a/src/maths/ni/nisenre.c +++ b/src/maths/ni/nisenre.c @@ -19,7 +19,7 @@ Author: 1985 Thomas L. Quarles #define CKALLOC(ptr,size,type) if(( ckt->ptr =\ -(type *) MALLOC((size)*sizeof(type))) == NULL) return(E_NOMEM); +TMALLOC(type, size)) == NULL) return(E_NOMEM); int NIsenReinit(CKTcircuit *ckt) diff --git a/src/maths/poly/interpolate.c b/src/maths/poly/interpolate.c index b4747d7ac..0d3fdabf8 100644 --- a/src/maths/poly/interpolate.c +++ b/src/maths/poly/interpolate.c @@ -55,11 +55,10 @@ ft_interpolate(double *data, double *ndata, double *oscale, int olen, else sign = 1; - scratch = (double *) tmalloc(((degree + 1) * (degree + 2)) * - sizeof (double)); - result = (double *) tmalloc((degree + 1) * sizeof (double)); - xdata = (double *) tmalloc((degree + 1) * sizeof (double)); - ydata = (double *) tmalloc((degree + 1) * sizeof (double)); + scratch = TMALLOC(double, (degree + 1) * (degree + 2)); + result = TMALLOC(double, degree + 1); + xdata = TMALLOC(double, degree + 1); + ydata = TMALLOC(double, degree + 1); /* Deal with the first degree pieces. */ bcopy(data, ydata, (degree + 1) * sizeof (double)); diff --git a/src/maths/sparse/spdefs.h b/src/maths/sparse/spdefs.h index 28de75631..85873a44b 100644 --- a/src/maths/sparse/spdefs.h +++ b/src/maths/sparse/spdefs.h @@ -371,7 +371,7 @@ extern void * trealloc(void *, size_t); #define SP_MALLOC(type,number) ((type *)tmalloc((size_t)(sizeof(type)*(number)))) #define SP_REALLOC(ptr,type,number) \ - ptr = (type *)trealloc((char *)ptr,(unsigned)(sizeof(type)*(number))) + ptr = (type *)trealloc(ptr,(unsigned)(sizeof(type)*(number))) #define SP_FREE(ptr) { if ((ptr) != NULL) txfree((char *)(ptr)); (ptr) = NULL; } @@ -383,7 +383,7 @@ extern void * trealloc(void *, size_t); } #else /* HAVE_LIBCG */ #define SP_CALLOC(ptr,type,number) \ -{ ptr = (type *) tmalloc(((size_t)number) * sizeof(type)); \ +{ ptr = TMALLOC(type, (size_t)number); \ } #endif diff --git a/src/misc/dstring.c b/src/misc/dstring.c index 7ebf34972..80ff8e101 100644 --- a/src/misc/dstring.c +++ b/src/misc/dstring.c @@ -4,7 +4,10 @@ DESCRIPTION:This file contains the routines for manipulating dynamic strings. CONTENTS: DATE: Wed Mar 24 18:38:28 CDT 2010 REVISIONS: $Log$ -REVISIONS: Revision 1.3 2010-10-09 11:42:10 rlar +REVISIONS: Revision 1.4 2010-10-28 19:32:34 rlar +REVISIONS: wrap tmalloc MALLOC etc, into two macros TMALLOC and TREALLOC +REVISIONS: +REVISIONS: Revision 1.3 2010/10/09 11:42:10 rlar REVISIONS: remove #define for EOS use '\0' instead REVISIONS: REVISIONS: Revision 1.2 2010/07/01 19:52:26 rlar @@ -90,7 +93,7 @@ char *spice_dstring_append(SPICE_DSTRINGPTR dsPtr,char *string,int length) ----------------------------------------------------------------- */ if (newSize >= dsPtr->spaceAvl) { dsPtr->spaceAvl = 2 * newSize ; - newString = (char*) tmalloc( dsPtr->spaceAvl * sizeof(char) ) ; + newString = TMALLOC(char, dsPtr->spaceAvl) ; memcpy((void *) newString, (void *) dsPtr->string, (size_t) dsPtr->length) ; if (dsPtr->string != dsPtr->staticSpace) { txfree(dsPtr->string) ; @@ -279,7 +282,7 @@ char *_spice_dstring_setlength(SPICE_DSTRINGPTR dsPtr,int length) if (length >= dsPtr->spaceAvl) { dsPtr->spaceAvl = length+1; - newString = (char*) tmalloc( dsPtr->spaceAvl * sizeof(char) ) ; + newString = TMALLOC(char, dsPtr->spaceAvl) ; /* ----------------------------------------------------------------- * SPECIAL NOTE: must use memcpy, not strcpy, to copy the string * to a larger buffer, since there may be embedded NULLs in the diff --git a/src/misc/ivars.c b/src/misc/ivars.c index f1a40eebc..581c05b7f 100644 --- a/src/misc/ivars.c +++ b/src/misc/ivars.c @@ -45,13 +45,12 @@ mkvar(char **p, char *path_prefix, char *var_dir, char *env_var) asprintf(p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir); #else /* ~ HAVE_ASPRINTF */ if (buffer){ - *p = (char *) tmalloc(strlen(buffer)+1); + *p = TMALLOC(char, strlen(buffer) + 1); sprintf(*p,"%s",buffer); /* asprintf(p, "%s", buffer); */ } else{ - *p = (char *) tmalloc(strlen(path_prefix) + - strlen(DIR_PATHSEP) + strlen(var_dir) + 1); + *p = TMALLOC(char, strlen(path_prefix) + strlen(DIR_PATHSEP) + strlen(var_dir) + 1); sprintf(*p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir); /* asprintf(p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir); */ } diff --git a/src/misc/mktemp.c b/src/misc/mktemp.c index 0c7ae2e2e..912863746 100644 --- a/src/misc/mktemp.c +++ b/src/misc/mktemp.c @@ -35,7 +35,7 @@ smktemp(char *id) id = "sp"; sprintf(rbuf, TEMPFORMAT, id, num); - nbuf = (char *) tmalloc(strlen(rbuf) + 1); + nbuf = TMALLOC(char, strlen(rbuf) + 1); strcpy(nbuf, rbuf); return nbuf; diff --git a/src/misc/string.c b/src/misc/string.c index cfc57fa9c..e6d075d78 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -28,7 +28,7 @@ copy(const char *str) { char *p; - if ((p = (char*) tmalloc(strlen(str) + 1))) + if ((p = TMALLOC(char, strlen(str) + 1))) (void) strcpy(p, str); return(p); } @@ -39,7 +39,7 @@ copy_substring(const char *str, const char *end) int n = end - str; char *p; - if ((p = (char*) tmalloc(n + 1))) { + if ((p = TMALLOC(char, n + 1))) { (void) strncpy(p, str, n); p[n] = '\0'; } diff --git a/src/misc/util.c b/src/misc/util.c index bef470d36..96833df9b 100644 --- a/src/misc/util.c +++ b/src/misc/util.c @@ -127,7 +127,7 @@ char * absolute_pathname(char *string, char *dot_path) result = copy(string); else { if (dot_path && dot_path[0]) { - result = (char*) tmalloc(2 + strlen(dot_path) + strlen(string)); + result = TMALLOC(char, 2 + strlen(dot_path) + strlen(string)); strcpy(result, dot_path); result_len = strlen(result); if (result[result_len - 1] != '/') { @@ -135,7 +135,7 @@ char * absolute_pathname(char *string, char *dot_path) result[result_len] = '\0'; } } else { - result = (char*) tmalloc(3 + strlen (string)); + result = TMALLOC(char, 3 + strlen (string)); result[0] = '.'; result[1] = '/'; result[2] = '\0'; result_len = 2; } @@ -171,7 +171,7 @@ basename(const char *name) len = strlen(name); if (name[len - 1] == '/') { // ditch the trailing '/' - p = tmp = (char*) tmalloc(len); + p = tmp = TMALLOC(char, len); strncpy(p, name, len - 1); } else { p = (char *) name; @@ -221,7 +221,7 @@ dirname(const char *name) size = p - name; if (size) { - ret = (char*) tmalloc(size + 1); + ret = TMALLOC(char, size + 1); memcpy(ret, name, size); ret[size] = '\0'; } else if (*p == '/') @@ -266,7 +266,7 @@ dirname(const char *name) size = p - name; if (size) { - ret = (char*) tmalloc(size + 1); + ret = TMALLOC(char, size + 1); memcpy(ret, name, size); ret[size] = '\0'; } else if (*p == '/') diff --git a/src/misc/wlist.c b/src/misc/wlist.c index d18bef713..e258f0d9b 100644 --- a/src/misc/wlist.c +++ b/src/misc/wlist.c @@ -144,7 +144,7 @@ wl_mkvec(wordlist *wl) char **v; len = wl_length(wl); - v = (char **) tmalloc((len + 1) * sizeof (char *)); + v = TMALLOC(char *, len + 1); for (i = 0; i < len; i++) { v[i] = copy(wl->wl_word); wl = wl->wl_next; @@ -198,7 +198,7 @@ wl_flatten(wordlist *wl) for (tw = wl; tw; tw = tw->wl_next) i += strlen(tw->wl_word) + 1; - buf = (char*) tmalloc(i + 1); + buf = TMALLOC(char, i + 1); *buf = 0; while (wl != NULL) { @@ -245,7 +245,7 @@ wl_sort(wordlist *wl) ww = ww->wl_next; if (i < 2) return; - stuff = (char **) tmalloc(i * sizeof (char *)); + stuff = TMALLOC(char *, i); for (i = 0, ww = wl; ww; i++, ww = ww->wl_next) stuff[i] = ww->wl_word; qsort(stuff, i, sizeof (char *), wlcomp); diff --git a/src/ngmultidec.c b/src/ngmultidec.c index 01fbd7054..ad15ba35d 100644 --- a/src/ngmultidec.c +++ b/src/ngmultidec.c @@ -57,7 +57,7 @@ main (int argc, char **argv) switch (ch) { case 'o': - name = (char *) tmalloc(strlen(optarg)*sizeof(char)); + name = TMALLOC(char, strlen(optarg)); (void) strcpy(name,optarg); gotname=1; use_opt = 1; @@ -158,13 +158,13 @@ main (int argc, char **argv) comments(r,l,g,c,ctot,cm,lm,k,name,num,len); - matrix = (double **) tmalloc(sizeof(double*)*(num+1)); - inverse = (double **) tmalloc(sizeof(double*)*(num+1)); - tpeigenvalues = (double *) tmalloc(sizeof(double)*(num+1)); + matrix = TMALLOC(double *, num + 1); + inverse = TMALLOC(double *, num + 1); + tpeigenvalues = TMALLOC(double, num + 1); for (i=1;i<=num;i++) { - matrix[i] = (double *) tmalloc(sizeof(double)*(num+1)); - inverse[i] = (double *) tmalloc(sizeof(double)*(num+1)); + matrix[i] = TMALLOC(double, num + 1); + inverse[i] = TMALLOC(double, num + 1); } for (i=1;i<=num;i++) { @@ -176,7 +176,7 @@ main (int argc, char **argv) matrix[i][j] = phi(i-1,tpeigenvalues[j]); } } - gammaj = (double *) tmalloc(sizeof(double)*(num+1)); + gammaj = TMALLOC(double, num + 1); for (j=1;j<=num;j++) { gammaj[j] = 0.0; @@ -203,10 +203,10 @@ main (int argc, char **argv) int errflg, err, singular_row, singular_col; double *elptr; - rhs = (double *) tmalloc(sizeof(double)*(num+1)); - irhs = (double *) tmalloc(sizeof(double)*(num+1)); - solution = (double *) tmalloc(sizeof(double)*(num+1)); - isolution = (double *) tmalloc(sizeof(double)*(num+1)); + rhs = TMALLOC(double, num + 1); + irhs = TMALLOC(double, num + 1); + solution = TMALLOC(double, num + 1); + isolution = TMALLOC(double, num + 1); othermatrix = spCreate(num,0,&errflg); @@ -264,7 +264,7 @@ main (int argc, char **argv) fprintf(stdout,"\n"); fprintf(stdout,"* Lossy line models\n"); - options = (char *) tmalloc(256); + options = TMALLOC(char, 256); (void) strcpy(options,"rel=1.2 nocontrol"); for (i=1;i<=num;i++) { fprintf(stdout,".model mod%d_%s ltra %s r=%0.12g l=%0.12g g=%0.12g c=%0.12g len=%0.12g\n", diff --git a/src/ngproc2mod.c b/src/ngproc2mod.c index 76537a26e..d40b1a0e1 100644 --- a/src/ngproc2mod.c +++ b/src/ngproc2mod.c @@ -56,9 +56,9 @@ main(void) { char *filename; - filename = (char *)tmalloc(1024); - typeline = (char *)tmalloc(1024); - dataline = (char *)tmalloc(1024); + filename = TMALLOC(char, 1024); + typeline = TMALLOC(char, 1024); + dataline = TMALLOC(char, 1024); while(p == NULL) { printf("name of process file (input): "); @@ -102,7 +102,7 @@ main(void) { } if(*typeline == 0) break; if(strncmp("nm",typeline,2) == 0) { - ncur = (nmod *)tmalloc(sizeof(nmod)); + ncur = TMALLOC(nmod, 1); ncur->nnext = NULL; ncur->nname = typeline; *(typeline+3) = '\0'; @@ -111,7 +111,7 @@ main(void) { ncur->nnext = nlist; nlist = ncur; } else if(strncmp("pm",typeline,2) == 0) { - pcur = (pmod *)tmalloc(sizeof(pmod)); + pcur = TMALLOC(pmod, 1); pcur->pnext = NULL; pcur->pname = typeline; *(typeline+3) = '\0'; @@ -120,7 +120,7 @@ main(void) { pcur->pnext = plist; plist = pcur; } else if(strncmp("py",typeline,2) == 0) { - ycur = (ymod *)tmalloc(sizeof(ymod)); + ycur = TMALLOC(ymod, 1); ycur->ynext = NULL; ycur->yname = typeline; *(typeline+3) = '\0'; @@ -129,7 +129,7 @@ main(void) { ycur->ynext = ylist; ylist = ycur; } else if(strncmp("du",typeline,2) == 0) { - dcur = (dmod *)tmalloc(sizeof(dmod)); + dcur = TMALLOC(dmod, 1); dcur->dnext = NULL; dcur->dname = typeline; *(typeline+3) = '\0'; @@ -138,7 +138,7 @@ main(void) { dcur->dnext = dlist; dlist = dcur; } else if(strncmp("ml",typeline,2) == 0) { - mcur = (mmod *)tmalloc(sizeof(mmod)); + mcur = TMALLOC(mmod, 1); mcur->mnext = NULL; mcur->mname = typeline; *(typeline+3) = '\0'; diff --git a/src/ngsconvert.c b/src/ngsconvert.c index 70d81e717..fe727d6c3 100644 --- a/src/ngsconvert.c +++ b/src/ngsconvert.c @@ -176,11 +176,9 @@ oldread(char *name) for (v = pl->pl_dvecs; v; v = v->v_next) { v->v_length = np; if (isreal(v)) { - v->v_realdata = (double *) tmalloc(sizeof (double) - * np); + v->v_realdata = TMALLOC(double, np); } else { - v->v_compdata = (ngcomplex_t *) tmalloc(sizeof(ngcomplex_t) - * np); + v->v_compdata = TMALLOC(ngcomplex_t, np); } } for (i = 0; i < np; i++) { diff --git a/src/spicelib/analysis/cktacdum.c b/src/spicelib/analysis/cktacdum.c index e7c8cf23c..2c10cf34e 100644 --- a/src/spicelib/analysis/cktacdum.c +++ b/src/spicelib/analysis/cktacdum.c @@ -30,7 +30,7 @@ CKTacDump(CKTcircuit *ckt, double freq, void *plot) irhsold = ckt->CKTirhsOld; freqData.rValue = freq; valueData.v.numValue = ckt->CKTmaxEqNum-1; - data = (IFcomplex *) MALLOC((ckt->CKTmaxEqNum-1)*sizeof(IFcomplex)); + data = TMALLOC(IFcomplex, ckt->CKTmaxEqNum - 1); valueData.v.vec.cVec = data; for (i=0;iCKTmaxEqNum-1;i++) { data[i].real = rhsold[i+1]; diff --git a/src/spicelib/analysis/cktclrbk.c b/src/spicelib/analysis/cktclrbk.c index f6786593d..c8171de0a 100644 --- a/src/spicelib/analysis/cktclrbk.c +++ b/src/spicelib/analysis/cktclrbk.c @@ -22,7 +22,7 @@ CKTclrBreak(CKTcircuit *ckt) int j; if(ckt->CKTbreakSize >2) { - tmp = (double *)MALLOC((ckt->CKTbreakSize-1)*sizeof(double)); + tmp = TMALLOC(double, ckt->CKTbreakSize - 1); if(tmp == (double *)NULL) return(E_NOMEM); for(j=1;jCKTbreakSize;j++) { *(tmp+j-1) = *(ckt->CKTbreaks+j); diff --git a/src/spicelib/analysis/cktgrnd.c b/src/spicelib/analysis/cktgrnd.c index 062379636..df9b3f98f 100644 --- a/src/spicelib/analysis/cktgrnd.c +++ b/src/spicelib/analysis/cktgrnd.c @@ -31,7 +31,7 @@ CKTground(CKTcircuit *inCkt, CKTnode **node, IFuid name) ckt->CKTnodes->type = SP_VOLTAGE; ckt->CKTnodes->number = 0; } else { - ckt->CKTnodes = (CKTnode *)MALLOC(sizeof(CKTnode)); + ckt->CKTnodes = TMALLOC(CKTnode, 1); if(ckt->CKTnodes == NULL) return(E_NOMEM); ckt->CKTnodes->name = name; ckt->CKTnodes->type = SP_VOLTAGE; diff --git a/src/spicelib/analysis/cktlnkeq.c b/src/spicelib/analysis/cktlnkeq.c index 1e05da52a..b01fc87fe 100644 --- a/src/spicelib/analysis/cktlnkeq.c +++ b/src/spicelib/analysis/cktlnkeq.c @@ -19,7 +19,7 @@ int CKTlinkEq(CKTcircuit *ckt, CKTnode *node) { if(!(ckt->CKTnodes)) { /* starting the list - allocate both ground and 1 */ - ckt->CKTnodes = (CKTnode *) MALLOC(sizeof(CKTnode)); + ckt->CKTnodes = TMALLOC(CKTnode, 1); if(ckt->CKTnodes == (CKTnode *)NULL) return(E_NOMEM); ckt->CKTnodes->name = (char *)NULL; ckt->CKTnodes->type = SP_VOLTAGE; diff --git a/src/spicelib/analysis/cktmknod.c b/src/spicelib/analysis/cktmknod.c index e763b968c..835917a0c 100644 --- a/src/spicelib/analysis/cktmknod.c +++ b/src/spicelib/analysis/cktmknod.c @@ -21,7 +21,7 @@ CKTmkNode(CKTcircuit *ckt, CKTnode **node) { CKTnode *mynode; - mynode = (CKTnode *)MALLOC(sizeof(CKTnode)); + mynode = TMALLOC(CKTnode, 1); if(mynode == (CKTnode *)NULL) return(E_NOMEM); mynode->next = (CKTnode *)NULL; mynode->name = (IFuid) 0; diff --git a/src/spicelib/analysis/cktnames.c b/src/spicelib/analysis/cktnames.c index 1e0a9b349..715ea99bc 100644 --- a/src/spicelib/analysis/cktnames.c +++ b/src/spicelib/analysis/cktnames.c @@ -21,7 +21,7 @@ CKTnames(CKTcircuit *ckt, int *numNames, IFuid **nameList) CKTnode *here; int i; *numNames = ckt->CKTmaxEqNum-1; - *nameList = (IFuid *)MALLOC(*numNames * sizeof(IFuid )); + *nameList = TMALLOC(IFuid, *numNames); if ((*nameList) == (IFuid *)NULL) return(E_NOMEM); i=0; for (here = ckt->CKTnodes->next; here; here = here->next) { diff --git a/src/spicelib/analysis/cktnewn.c b/src/spicelib/analysis/cktnewn.c index f0ee91a2e..3a7f895dc 100644 --- a/src/spicelib/analysis/cktnewn.c +++ b/src/spicelib/analysis/cktnewn.c @@ -24,14 +24,14 @@ CKTnewNode(CKTcircuit *inCkt, CKTnode **node, IFuid name) { CKTcircuit *ckt = /* fixme, drop that */ inCkt; if(!(ckt->CKTnodes)) { /* starting the list - allocate both ground and 1 */ - ckt->CKTnodes = (CKTnode *) MALLOC(sizeof(CKTnode)); + ckt->CKTnodes = TMALLOC(CKTnode, 1); if(ckt->CKTnodes == (CKTnode *)NULL) return(E_NOMEM); ckt->CKTnodes->name = (char *)NULL; ckt->CKTnodes->type = SP_VOLTAGE; ckt->CKTnodes->number = 0; ckt->CKTlastNode = ckt->CKTnodes; } - ckt->CKTlastNode->next = (CKTnode *)MALLOC(sizeof(CKTnode)); + ckt->CKTlastNode->next = TMALLOC(CKTnode, 1); if(ckt->CKTlastNode->next == (CKTnode *)NULL) return(E_NOMEM); ckt->CKTlastNode = ckt->CKTlastNode->next; ckt->CKTlastNode->name = name; diff --git a/src/spicelib/analysis/cktnoise.c b/src/spicelib/analysis/cktnoise.c index 9ca6328f6..0bf8df303 100644 --- a/src/spicelib/analysis/cktnoise.c +++ b/src/spicelib/analysis/cktnoise.c @@ -51,14 +51,12 @@ CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data) case N_DENS: - data->namelist = (IFuid *)trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), (IFuid)NULL, "onoise_spectrum", UID_OTHER, NULL); - data->namelist = (IFuid *)trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), (IFuid)NULL, "inoise_spectrum", UID_OTHER, NULL); @@ -66,24 +64,22 @@ CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data) /* we've added two more plots */ data->outpVector = - (double *)MALLOC(data->numPlots * sizeof(double)); + TMALLOC(double, data->numPlots); break; case INT_NOIZ: - data->namelist = (IFuid *)trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), (IFuid)NULL, "onoise_total", UID_OTHER, NULL); - data->namelist = (IFuid *)trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), (IFuid)NULL, "inoise_total", UID_OTHER, NULL); /* we've added two more plots */ data->outpVector = - (double *) MALLOC(data->numPlots * sizeof(double)); + TMALLOC(double, data->numPlots); break; default: diff --git a/src/spicelib/analysis/cktntask.c b/src/spicelib/analysis/cktntask.c index 75d5a5eea..5d18aa5b0 100644 --- a/src/spicelib/analysis/cktntask.c +++ b/src/spicelib/analysis/cktntask.c @@ -24,7 +24,7 @@ CKTnewTask(CKTcircuit *ckt, TSKtask **taskPtr, IFuid taskName, TSKtask **defPtr) { TSKtask *tsk, *def=NULL; - *taskPtr = (TSKtask *)tmalloc(sizeof(TSKtask)); + *taskPtr = TMALLOC(TSKtask, 1); if(*taskPtr==NULL) return(E_NOMEM); tsk = *taskPtr; tsk->TSKname = taskName; diff --git a/src/spicelib/analysis/cktop.c b/src/spicelib/analysis/cktop.c index d8b686d5e..1911f73bb 100644 --- a/src/spicelib/analysis/cktop.c +++ b/src/spicelib/analysis/cktop.c @@ -169,9 +169,9 @@ dynamic_gmin (CKTcircuit * ckt, long int firstmode, for (n = ckt->CKTnodes; n; n = n->next) NumNodes++; - OldRhsOld = (double *) MALLOC ((NumNodes + 1) * sizeof (double)); + OldRhsOld = TMALLOC(double, NumNodes + 1); OldCKTstate0 = - (double *) MALLOC ((ckt->CKTnumStates + 1) * sizeof (double)); + TMALLOC(double, ckt->CKTnumStates + 1); for (n = ckt->CKTnodes; n; n = n->next) *(ckt->CKTrhsOld + n->number) = 0; @@ -406,9 +406,9 @@ gillespie_src (CKTcircuit * ckt, long int firstmode, NumNodes++; } - OldRhsOld = (double *) MALLOC ((NumNodes + 1) * sizeof (double)); + OldRhsOld = TMALLOC(double, NumNodes + 1); OldCKTstate0 = - (double *) MALLOC ((ckt->CKTnumStates + 1) * sizeof (double)); + TMALLOC(double, ckt->CKTnumStates + 1); for (n = ckt->CKTnodes; n; n = n->next) *(ckt->CKTrhsOld + n->number) = 0; diff --git a/src/spicelib/analysis/cktsetbk.c b/src/spicelib/analysis/cktsetbk.c index 7221fec31..3d3cbb292 100644 --- a/src/spicelib/analysis/cktsetbk.c +++ b/src/spicelib/analysis/cktsetbk.c @@ -53,7 +53,7 @@ CKTsetBreak(CKTcircuit *ckt, double time) return(OK); } /* fits in middle - new array & insert */ - tmp = (double *)MALLOC((ckt->CKTbreakSize+1)*sizeof(double)); + tmp = TMALLOC(double, ckt->CKTbreakSize + 1); if(tmp == (double *)NULL) return(E_NOMEM); for(j=0;jCKTbreaks+j); @@ -83,8 +83,7 @@ CKTsetBreak(CKTcircuit *ckt, double time) return(OK); } /* fits at end - grow array & add on */ - ckt->CKTbreaks = (double *)REALLOC(ckt->CKTbreaks, - (ckt->CKTbreakSize+1)*sizeof(double)); + ckt->CKTbreaks = TREALLOC(double, ckt->CKTbreaks, ckt->CKTbreakSize + 1); ckt->CKTbreakSize++; ckt->CKTbreaks[ckt->CKTbreakSize-1]=time; #ifdef TRACE_BREAKPOINT diff --git a/src/spicelib/analysis/cktsetup.c b/src/spicelib/analysis/cktsetup.c index 99db309d9..c70d79665 100644 --- a/src/spicelib/analysis/cktsetup.c +++ b/src/spicelib/analysis/cktsetup.c @@ -18,7 +18,7 @@ Author: 1985 Thomas L. Quarles #define CKALLOC(var,size,type) \ - if(size && (!(var =(type *)MALLOC((size)*sizeof(type))))){\ + if(size && (!(var = TMALLOC(type, size)))){\ return(E_NOMEM);\ } @@ -97,7 +97,7 @@ CKTsetup(CKTcircuit *ckt) /* Allocate space for the matrix diagonal data */ if(num_nodes > 0) { ckt->enh->rshunt_data.diag = - (double **) MALLOC(num_nodes * sizeof(double *)); + TMALLOC(double *, num_nodes); } /* Set the number of nodes in the rshunt data */ diff --git a/src/spicelib/analysis/ckttroub.c b/src/spicelib/analysis/ckttroub.c index 4773c74fd..e47bced48 100644 --- a/src/spicelib/analysis/ckttroub.c +++ b/src/spicelib/analysis/ckttroub.c @@ -89,7 +89,7 @@ CKTtrouble(CKTcircuit *cktp, char *optmsg) sprintf(msg_p, "cause unrecorded.\n"); } - emsg = (char*) MALLOC(strlen(msg_buf)+1); + emsg = TMALLOC(char, strlen(msg_buf) + 1); strcpy(emsg,msg_buf); return emsg; diff --git a/src/spicelib/analysis/cluster.c b/src/spicelib/analysis/cluster.c index 4d8f8bfb8..c941bf798 100755 --- a/src/spicelib/analysis/cluster.c +++ b/src/spicelib/analysis/cluster.c @@ -88,7 +88,7 @@ int CLUsetup(CKTcircuit *ckt){ /* allocate the input connections */ for(i=0;inext = input_pipes; else @@ -132,7 +132,7 @@ static int setup_output(CKTcircuit *ckt){ int sock,nodeNum,i; /*Create the struct*/ - curr = (struct output_pipe *)tmalloc(sizeof(struct output_pipe)); + curr = TMALLOC(struct output_pipe, 1); if(output_pipes) curr->next = output_pipes; else diff --git a/src/spicelib/analysis/dctran.c b/src/spicelib/analysis/dctran.c index f6c987a42..4a8afcb1f 100644 --- a/src/spicelib/analysis/dctran.c +++ b/src/spicelib/analysis/dctran.c @@ -107,7 +107,7 @@ DCtran(CKTcircuit *ckt, /* end LTRA code addition */ if(ckt->CKTbreaks) FREE(ckt->CKTbreaks); - ckt->CKTbreaks=(double *)MALLOC(2*sizeof(double)); + ckt->CKTbreaks = TMALLOC(double, 2); if(ckt->CKTbreaks == (double *)NULL) return(E_NOMEM); *(ckt->CKTbreaks)=0; *(ckt->CKTbreaks+1)=ckt->CKTfinalTime; @@ -358,8 +358,7 @@ nextTime: if (need < ckt->CKTsizeIncr) need = ckt->CKTsizeIncr; ckt->CKTtimeListSize += need; - ckt->CKTtimePoints = (double *) REALLOC( (char *) - ckt->CKTtimePoints, sizeof(double) * ckt->CKTtimeListSize); + ckt->CKTtimePoints = TREALLOC(double, ckt->CKTtimePoints, ckt->CKTtimeListSize); ckt->CKTsizeIncr *= 1.4; } *(ckt->CKTtimePoints + ckt->CKTtimeIndex) = ckt->CKTtime; diff --git a/src/spicelib/analysis/distoan.c b/src/spicelib/analysis/distoan.c index ba6ccacab..903426f92 100644 --- a/src/spicelib/analysis/distoan.c +++ b/src/spicelib/analysis/distoan.c @@ -22,7 +22,7 @@ c = *a; static void DmemAlloc(double **a, int size) { -*a = (double *) MALLOC( sizeof(double) * (size + 1)); +*a = TMALLOC(double, size + 1); } @@ -30,7 +30,7 @@ DmemAlloc(double **a, int size) static void DstorAlloc(double ***header, int size) { -*header = (double **) MALLOC( sizeof(double *)*size); +*header = TMALLOC(double *, size); } @@ -420,7 +420,7 @@ printf("Time outside D_2F1MF2: %g seconds \n", time); } else { - errMsg = (char*) MALLOC(strlen(nof2src)+1); + errMsg = TMALLOC(char, strlen(nof2src) + 1); strcpy(errMsg,nof2src); return(E_NOF2SRC); } diff --git a/src/spicelib/analysis/noisean.c b/src/spicelib/analysis/noisean.c index 728d5730a..0781bc9d7 100644 --- a/src/spicelib/analysis/noisean.c +++ b/src/spicelib/analysis/noisean.c @@ -51,7 +51,7 @@ NOISEan (CKTcircuit *ckt, int restart) error = CKTfndDev(ckt, &code, &inst, job->input, (GENmodel *)NULL, (IFuid)NULL); if (!error && !((VSRCinstance *)inst)->VSRCacGiven) { - errMsg = (char*) MALLOC(strlen(noacinput)+1); + errMsg = TMALLOC(char, strlen(noacinput) + 1); strcpy(errMsg,noacinput); return (E_NOACINPUT); } @@ -69,7 +69,7 @@ NOISEan (CKTcircuit *ckt, int restart) return (E_NOTFOUND); } if (!((ISRCinstance *)inst)->ISRCacGiven) { - errMsg = (char*) MALLOC(strlen(noacinput)+1); + errMsg = TMALLOC(char, strlen(noacinput) + 1); strcpy(errMsg,noacinput); return (E_NOACINPUT); } @@ -111,7 +111,7 @@ NOISEan (CKTcircuit *ckt, int restart) error = CKTload(ckt); if(error) return(error); - data = (Ndata*)MALLOC(sizeof(Ndata)); + data = TMALLOC(Ndata, 1); step = 0; data->freq = job->NstartFreq; data->outNoiz = 0.0; diff --git a/src/spicelib/analysis/pzan.c b/src/spicelib/analysis/pzan.c index cfbb8165d..e8aeb250a 100644 --- a/src/spicelib/analysis/pzan.c +++ b/src/spicelib/analysis/pzan.c @@ -130,10 +130,8 @@ PZpost(CKTcircuit *ckt) char name[50]; int i, j; - namelist = (IFuid *) MALLOC((pzan->PZnPoles - + pzan->PZnZeros)*sizeof(IFuid)); - out_list = (IFcomplex *)MALLOC((pzan->PZnPoles - + pzan->PZnZeros)*sizeof(IFcomplex)); + namelist = TMALLOC(IFuid, pzan->PZnPoles + pzan->PZnZeros); + out_list = TMALLOC(IFcomplex, pzan->PZnPoles + pzan->PZnZeros); j = 0; for (i = 0; i < pzan->PZnPoles; i++) { diff --git a/src/spicelib/analysis/tfanal.c b/src/spicelib/analysis/tfanal.c index 44b36f2c2..75a57cb4a 100644 --- a/src/spicelib/analysis/tfanal.c +++ b/src/spicelib/analysis/tfanal.c @@ -103,8 +103,7 @@ TFanal(CKTcircuit *ckt, int restart) (*(SPfrontEnd->IFnewUid))(ckt,&outuid,((TFan*)ckt->CKTcurJob)->TFoutSrc ,"Output_impedance", UID_OTHER, NULL); } else { - name = (char *) - MALLOC(sizeof(char)*(strlen(((TFan*)ckt->CKTcurJob)->TFoutName)+22)); + name = TMALLOC(char, strlen(((TFan*)ckt->CKTcurJob)->TFoutName) + 22); (void)sprintf(name,"output_impedance_at_%s", ((TFan*)ckt->CKTcurJob)->TFoutName); (*(SPfrontEnd->IFnewUid))(ckt,&outuid,(IFuid)NULL, diff --git a/src/spicelib/devices/asrc/asrcset.c b/src/spicelib/devices/asrc/asrcset.c index 7844f952a..4e093cffa 100644 --- a/src/spicelib/devices/asrc/asrcset.c +++ b/src/spicelib/devices/asrc/asrcset.c @@ -71,8 +71,7 @@ if((here->ptr = SMPmakeElt(matrix, here->first, (second)->number))\ return(E_UNSUPP); } - here->ASRCposptr = (double **) - REALLOC(here->ASRCposptr, sizeof(double *)*(j+5)); + here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 5); TSTALLOC(ASRCposptr[j++],ASRCposNode,ASRCbranch); TSTALLOC(ASRCposptr[j++],ASRCnegNode,ASRCbranch); TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCnegNode); @@ -98,14 +97,12 @@ if((here->ptr = SMPmakeElt(matrix, here->first, (second)->number))\ TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCcont_br); v_first = 0; } else{ - here->ASRCposptr = (double **) - REALLOC(here->ASRCposptr, sizeof(double *)*(j+1)); + here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1); TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCcont_br); } } else if(here->ASRCtype == ASRC_CURRENT){ /* CCCS */ - here->ASRCposptr = (double **) - REALLOC(here->ASRCposptr, sizeof(double *) * (j+2)); + here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2); TSTALLOC(ASRCposptr[j++],ASRCposNode,ASRCcont_br); TSTALLOC(ASRCposptr[j++],ASRCnegNode,ASRCcont_br); } else{ @@ -119,14 +116,12 @@ if((here->ptr = SMPmakeElt(matrix, here->first, (second)->number))\ MY_TSTALLOC(ASRCposptr[j++],ASRCbranch,here->ASRCtree->vars[i].nValue); v_first = 0; } else{ - here->ASRCposptr = (double **) - REALLOC(here->ASRCposptr, sizeof(double *) * (j+1)); + here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1); MY_TSTALLOC(ASRCposptr[j++],ASRCbranch,here->ASRCtree->vars[i].nValue); } } else if(here->ASRCtype == ASRC_CURRENT){ /* VCCS */ - here->ASRCposptr = (double **) - REALLOC(here->ASRCposptr, sizeof(double *) * (j+2)); + here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2); MY_TSTALLOC(ASRCposptr[j++],ASRCposNode,here->ASRCtree->vars[i].nValue); MY_TSTALLOC(ASRCposptr[j++],ASRCnegNode,here->ASRCtree->vars[i].nValue); } else{ diff --git a/src/spicelib/devices/bjt/bjtask.c b/src/spicelib/devices/bjt/bjtask.c index 9800c11e0..dc5fcd7cf 100644 --- a/src/spicelib/devices/bjt/bjtask.c +++ b/src/spicelib/devices/bjt/bjtask.c @@ -228,7 +228,7 @@ BJTask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalue return(OK); case BJT_QUEST_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "BJTask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -243,7 +243,7 @@ BJTask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalue return(OK); case BJT_QUEST_CE : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "BJTask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -258,7 +258,7 @@ BJTask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalue return(OK); case BJT_QUEST_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "BJTask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/bjt/bjtnoise.c b/src/spicelib/devices/bjt/bjtnoise.c index 6f31109b7..861977e43 100644 --- a/src/spicelib/devices/bjt/bjtnoise.c +++ b/src/spicelib/devices/bjt/bjtnoise.c @@ -70,9 +70,7 @@ BJTnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, inst->BJTname,BJTnNames[i]); - data->namelist = (IFuid *) - trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -86,9 +84,7 @@ BJTnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"onoise_total_%s%s", inst->BJTname,BJTnNames[i]); - data->namelist = (IFuid *) - trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -98,7 +94,7 @@ BJTnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"inoise_total_%s%s", inst->BJTname,BJTnNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/bjt/bjtsset.c b/src/spicelib/devices/bjt/bjtsset.c index e55ff28a1..ace4b3f77 100644 --- a/src/spicelib/devices/bjt/bjtsset.c +++ b/src/spicelib/devices/bjt/bjtsset.c @@ -42,7 +42,7 @@ BJTsSetup(SENstruct *info, GENmodel *inModel) here->BJTsenParmNo = ++(info->SENparms); here->BJTsenPertFlag = OFF; } - if((here->BJTsens = (double *)MALLOC(55*sizeof(double))) == + if((here->BJTsens = TMALLOC(double, 55)) == NULL) return(E_NOMEM); } } diff --git a/src/spicelib/devices/bjt2/bjt2ask.c b/src/spicelib/devices/bjt2/bjt2ask.c index a1b92e6d5..7a47f080e 100644 --- a/src/spicelib/devices/bjt2/bjt2ask.c +++ b/src/spicelib/devices/bjt2/bjt2ask.c @@ -241,7 +241,7 @@ BJT2ask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, return(OK); case BJT2_QUEST_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "BJT2ask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -259,7 +259,7 @@ BJT2ask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, return(OK); case BJT2_QUEST_CE : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "BJT2ask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -278,7 +278,7 @@ BJT2ask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, return(OK); case BJT2_QUEST_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "BJT2ask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/bjt2/bjt2noise.c b/src/spicelib/devices/bjt2/bjt2noise.c index 5f343696a..36fe327de 100644 --- a/src/spicelib/devices/bjt2/bjt2noise.c +++ b/src/spicelib/devices/bjt2/bjt2noise.c @@ -68,9 +68,7 @@ BJT2noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, inst->BJT2name,BJT2nNames[i]); - data->namelist = (IFuid *) - trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -84,9 +82,7 @@ BJT2noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"onoise_total_%s%s", inst->BJT2name,BJT2nNames[i]); - data->namelist = (IFuid *) - trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -96,7 +92,7 @@ BJT2noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"inoise_total_%s%s", inst->BJT2name,BJT2nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/bjt2/bjt2sset.c b/src/spicelib/devices/bjt2/bjt2sset.c index 5cb5ed0ee..6ae37088a 100644 --- a/src/spicelib/devices/bjt2/bjt2sset.c +++ b/src/spicelib/devices/bjt2/bjt2sset.c @@ -43,7 +43,7 @@ BJT2sSetup(SENstruct *info, GENmodel *inModel) here->BJT2senParmNo = ++(info->SENparms); here->BJT2senPertFlag = OFF; } - if((here->BJT2sens = (double *)MALLOC(55*sizeof(double))) == + if((here->BJT2sens = TMALLOC(double, 55)) == NULL) return(E_NOMEM); } } diff --git a/src/spicelib/devices/bsim1/b1noi.c b/src/spicelib/devices/bsim1/b1noi.c index 81f5639e1..649495abf 100644 --- a/src/spicelib/devices/bsim1/b1noi.c +++ b/src/spicelib/devices/bsim1/b1noi.c @@ -63,7 +63,7 @@ B1noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"onoise_%s%s",inst->B1name,B1nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -79,7 +79,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s%s",inst->B1name,B1nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -90,7 +90,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s%s",inst->B1name,B1nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/bsim2/b2noi.c b/src/spicelib/devices/bsim2/b2noi.c index 7db2c3643..909b8caf3 100644 --- a/src/spicelib/devices/bsim2/b2noi.c +++ b/src/spicelib/devices/bsim2/b2noi.c @@ -63,7 +63,7 @@ B2noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"onoise_%s%s",inst->B2name,B2nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -79,7 +79,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s%s",inst->B2name,B2nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -90,7 +90,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s%s",inst->B2name,B2nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/bsim2/b2temp.c b/src/spicelib/devices/bsim2/b2temp.c index 1f7dd7771..acf57e8f4 100644 --- a/src/spicelib/devices/bsim2/b2temp.c +++ b/src/spicelib/devices/bsim2/b2temp.c @@ -68,8 +68,7 @@ B2temp(GENmodel *inModel, CKTcircuit *ckt) } if (Size_Not_Found) - { here->pParam = (struct bsim2SizeDependParam *)tmalloc( - sizeof(struct bsim2SizeDependParam)); + { here->pParam = TMALLOC(struct bsim2SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = here->pParam; else diff --git a/src/spicelib/devices/bsim3/b3noi.c b/src/spicelib/devices/bsim3/b3noi.c index 471700e94..ddd188a6b 100644 --- a/src/spicelib/devices/bsim3/b3noi.c +++ b/src/spicelib/devices/bsim3/b3noi.c @@ -154,10 +154,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM3name, BSIM3nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -172,10 +169,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM3name, BSIM3nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -187,10 +181,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM3name, BSIM3nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim3/b3set.c b/src/spicelib/devices/bsim3/b3set.c index 1541d5fc6..3dc91802f 100644 --- a/src/spicelib/devices/bsim3/b3set.c +++ b/src/spicelib/devices/bsim3/b3set.c @@ -1033,7 +1033,7 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\ InstCount++; } } - InstArray = (BSIM3instance**)tmalloc(InstCount*sizeof(BSIM3instance*)); + InstArray = TMALLOC(BSIM3instance*, InstCount); model = (BSIM3model*)inModel; idx = 0; for( ; model != NULL; model = model->BSIM3nextModel ) diff --git a/src/spicelib/devices/bsim3/b3temp.c b/src/spicelib/devices/bsim3/b3temp.c index f2676027f..7f293da98 100644 --- a/src/spicelib/devices/bsim3/b3temp.c +++ b/src/spicelib/devices/bsim3/b3temp.c @@ -163,8 +163,7 @@ int Size_Not_Found; } if (Size_Not_Found) - { pParam = (struct bsim3SizeDependParam *)tmalloc( - sizeof(struct bsim3SizeDependParam)); + { pParam = TMALLOC(struct bsim3SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim3soi/b4soinoi.c b/src/spicelib/devices/bsim3soi/b4soinoi.c index fda12156f..c30fe2e0d 100644 --- a/src/spicelib/devices/bsim3soi/b4soinoi.c +++ b/src/spicelib/devices/bsim3soi/b4soinoi.c @@ -163,10 +163,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->B4SOIname, B4SOInNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -181,10 +178,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->B4SOIname, B4SOInNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -196,10 +190,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->B4SOIname, B4SOInNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim3soi/b4soiset.c b/src/spicelib/devices/bsim3soi/b4soiset.c index 1a66ffceb..64b19fdd3 100644 --- a/src/spicelib/devices/bsim3soi/b4soiset.c +++ b/src/spicelib/devices/bsim3soi/b4soiset.c @@ -2693,7 +2693,7 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\ InstCount++; } } - InstArray = (B4SOIinstance**)tmalloc(InstCount*sizeof(B4SOIinstance*)); + InstArray = TMALLOC(B4SOIinstance*, InstCount); model = (B4SOImodel*)inModel; idx = 0; for( ; model != NULL; model = model->B4SOInextModel ) diff --git a/src/spicelib/devices/bsim3soi/b4soitemp.c b/src/spicelib/devices/bsim3soi/b4soitemp.c index 0d8a5ae62..c15924d86 100644 --- a/src/spicelib/devices/bsim3soi/b4soitemp.c +++ b/src/spicelib/devices/bsim3soi/b4soitemp.c @@ -185,8 +185,7 @@ B4SOItemp( } if (Size_Not_Found) - { pParam = (struct b4soiSizeDependParam *)tmalloc( - sizeof(struct b4soiSizeDependParam)); + { pParam = TMALLOC(struct b4soiSizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim3soi_dd/b3soiddnoi.c b/src/spicelib/devices/bsim3soi_dd/b3soiddnoi.c index c4f4f47bf..f4d9d1d50 100644 --- a/src/spicelib/devices/bsim3soi_dd/b3soiddnoi.c +++ b/src/spicelib/devices/bsim3soi_dd/b3soiddnoi.c @@ -147,10 +147,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->B3SOIDDname, B3SOIDDnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -165,10 +162,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->B3SOIDDname, B3SOIDDnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -180,10 +174,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->B3SOIDDname, B3SOIDDnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim3soi_dd/b3soiddtemp.c b/src/spicelib/devices/bsim3soi_dd/b3soiddtemp.c index d76531645..04cb111e1 100644 --- a/src/spicelib/devices/bsim3soi_dd/b3soiddtemp.c +++ b/src/spicelib/devices/bsim3soi_dd/b3soiddtemp.c @@ -98,8 +98,7 @@ int Size_Not_Found; } if (Size_Not_Found) - { pParam = (struct b3soiddSizeDependParam *)tmalloc( - sizeof(struct b3soiddSizeDependParam)); + { pParam = TMALLOC(struct b3soiddSizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim3soi_fd/b3soifdnoi.c b/src/spicelib/devices/bsim3soi_fd/b3soifdnoi.c index dd8368a62..227da33a8 100644 --- a/src/spicelib/devices/bsim3soi_fd/b3soifdnoi.c +++ b/src/spicelib/devices/bsim3soi_fd/b3soifdnoi.c @@ -147,10 +147,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->B3SOIFDname, B3SOIFDnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -165,10 +162,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->B3SOIFDname, B3SOIFDnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -180,10 +174,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->B3SOIFDname, B3SOIFDnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim3soi_fd/b3soifdtemp.c b/src/spicelib/devices/bsim3soi_fd/b3soifdtemp.c index e9982c12a..907058c0b 100644 --- a/src/spicelib/devices/bsim3soi_fd/b3soifdtemp.c +++ b/src/spicelib/devices/bsim3soi_fd/b3soifdtemp.c @@ -97,8 +97,7 @@ int Size_Not_Found; } if (Size_Not_Found) - { pParam = (struct b3soifdSizeDependParam *)tmalloc( - sizeof(struct b3soifdSizeDependParam)); + { pParam = TMALLOC(struct b3soifdSizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim3soi_pd/b3soipdnoi.c b/src/spicelib/devices/bsim3soi_pd/b3soipdnoi.c index e30b2d8b3..d2ec385f2 100644 --- a/src/spicelib/devices/bsim3soi_pd/b3soipdnoi.c +++ b/src/spicelib/devices/bsim3soi_pd/b3soipdnoi.c @@ -149,10 +149,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->B3SOIPDname, B3SOIPDnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -167,10 +164,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->B3SOIPDname, B3SOIPDnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -182,10 +176,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->B3SOIPDname, B3SOIPDnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim3soi_pd/b3soipdtemp.c b/src/spicelib/devices/bsim3soi_pd/b3soipdtemp.c index da5a045b4..0f104fd88 100644 --- a/src/spicelib/devices/bsim3soi_pd/b3soipdtemp.c +++ b/src/spicelib/devices/bsim3soi_pd/b3soipdtemp.c @@ -117,8 +117,7 @@ double tmp3, T7; } if (Size_Not_Found) - { pParam = (struct b3soipdSizeDependParam *)tmalloc( - sizeof(struct b3soipdSizeDependParam)); + { pParam = TMALLOC(struct b3soipdSizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim3v0/b3v0noi.c b/src/spicelib/devices/bsim3v0/b3v0noi.c index 9a107d280..3fe209477 100644 --- a/src/spicelib/devices/bsim3v0/b3v0noi.c +++ b/src/spicelib/devices/bsim3v0/b3v0noi.c @@ -120,10 +120,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM3v0name, BSIM3v0nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -138,10 +135,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM3v0name, BSIM3v0nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -153,10 +147,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM3v0name, BSIM3v0nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim3v0/b3v0temp.c b/src/spicelib/devices/bsim3v0/b3v0temp.c index a6cbc2610..b241fd2a9 100644 --- a/src/spicelib/devices/bsim3v0/b3v0temp.c +++ b/src/spicelib/devices/bsim3v0/b3v0temp.c @@ -71,8 +71,7 @@ int Size_Not_Found; } if (Size_Not_Found) - { pParam = (struct bsim3v0SizeDependParam *)tmalloc( - sizeof(struct bsim3v0SizeDependParam)); + { pParam = TMALLOC(struct bsim3v0SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim3v1/b3v1noi.c b/src/spicelib/devices/bsim3v1/b3v1noi.c index 8938eb630..3289bbbad 100644 --- a/src/spicelib/devices/bsim3v1/b3v1noi.c +++ b/src/spicelib/devices/bsim3v1/b3v1noi.c @@ -143,10 +143,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM3v1name, BSIM3v1nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -161,10 +158,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM3v1name, BSIM3v1nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -176,10 +170,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM3v1name, BSIM3v1nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim3v1/b3v1temp.c b/src/spicelib/devices/bsim3v1/b3v1temp.c index 20544905f..f787dd6cf 100644 --- a/src/spicelib/devices/bsim3v1/b3v1temp.c +++ b/src/spicelib/devices/bsim3v1/b3v1temp.c @@ -111,8 +111,7 @@ int Size_Not_Found; } if (Size_Not_Found) - { pParam = (struct bsim3v1SizeDependParam *)tmalloc( - sizeof(struct bsim3v1SizeDependParam)); + { pParam = TMALLOC(struct bsim3v1SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim3v1a/b3v1anoi.c b/src/spicelib/devices/bsim3v1a/b3v1anoi.c index 5965cd446..ad40167d1 100644 --- a/src/spicelib/devices/bsim3v1a/b3v1anoi.c +++ b/src/spicelib/devices/bsim3v1a/b3v1anoi.c @@ -121,10 +121,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM3v1Aname, BSIM3v1AnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -139,10 +136,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM3v1Aname, BSIM3v1AnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -154,10 +148,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM3v1Aname, BSIM3v1AnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim3v1a/b3v1atemp.c b/src/spicelib/devices/bsim3v1a/b3v1atemp.c index cf088ca06..149c906a7 100644 --- a/src/spicelib/devices/bsim3v1a/b3v1atemp.c +++ b/src/spicelib/devices/bsim3v1a/b3v1atemp.c @@ -72,8 +72,7 @@ int Size_Not_Found; } if (Size_Not_Found) - { pParam = (struct bsim3v1aSizeDependParam *)tmalloc( - sizeof(struct bsim3v1aSizeDependParam)); + { pParam = TMALLOC(struct bsim3v1aSizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim3v1s/b3v1snoi.c b/src/spicelib/devices/bsim3v1s/b3v1snoi.c index 86eef0020..9e109745e 100644 --- a/src/spicelib/devices/bsim3v1s/b3v1snoi.c +++ b/src/spicelib/devices/bsim3v1s/b3v1snoi.c @@ -134,10 +134,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM3v1Sname, BSIM3v1SnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -152,10 +149,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM3v1Sname, BSIM3v1SnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -167,10 +161,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM3v1Sname, BSIM3v1SnNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim3v1s/b3v1stemp.c b/src/spicelib/devices/bsim3v1s/b3v1stemp.c index 0c1f26c26..3c4c5e3f4 100644 --- a/src/spicelib/devices/bsim3v1s/b3v1stemp.c +++ b/src/spicelib/devices/bsim3v1s/b3v1stemp.c @@ -105,8 +105,7 @@ int Size_Not_Found; } if (Size_Not_Found) - { pParam = (struct bsim3v1sSizeDependParam *)tmalloc( - sizeof(struct bsim3v1sSizeDependParam)); + { pParam = TMALLOC(struct bsim3v1sSizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim3v32/b3v32noi.c b/src/spicelib/devices/bsim3v32/b3v32noi.c index b617f32b4..dd601a858 100644 --- a/src/spicelib/devices/bsim3v32/b3v32noi.c +++ b/src/spicelib/devices/bsim3v32/b3v32noi.c @@ -223,10 +223,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM3v32name, BSIM3v32nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -241,10 +238,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM3v32name, BSIM3v32nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -256,10 +250,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM3v32name, BSIM3v32nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim3v32/b3v32temp.c b/src/spicelib/devices/bsim3v32/b3v32temp.c index 551c496cf..2215dcdc8 100644 --- a/src/spicelib/devices/bsim3v32/b3v32temp.c +++ b/src/spicelib/devices/bsim3v32/b3v32temp.c @@ -232,8 +232,7 @@ int Size_Not_Found; } if (Size_Not_Found) - { pParam = (struct bsim3SizeDependParam *)tmalloc( - sizeof(struct bsim3SizeDependParam)); + { pParam = TMALLOC(struct bsim3SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim4/b4noi.c b/src/spicelib/devices/bsim4/b4noi.c index 787f2550f..d9511116f 100644 --- a/src/spicelib/devices/bsim4/b4noi.c +++ b/src/spicelib/devices/bsim4/b4noi.c @@ -135,10 +135,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM4name, BSIM4nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -153,10 +150,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM4name, BSIM4nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -168,10 +162,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM4name, BSIM4nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim4/b4set.c b/src/spicelib/devices/bsim4/b4set.c index 3d23bd69f..dabc7999d 100644 --- a/src/spicelib/devices/bsim4/b4set.c +++ b/src/spicelib/devices/bsim4/b4set.c @@ -2408,7 +2408,7 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\ InstCount++; } } - InstArray = (BSIM4instance**)tmalloc(InstCount*sizeof(BSIM4instance*)); + InstArray = TMALLOC(BSIM4instance*, InstCount); model = (BSIM4model*)inModel; idx = 0; for( ; model != NULL; model = model->BSIM4nextModel ) diff --git a/src/spicelib/devices/bsim4/b4temp.c b/src/spicelib/devices/bsim4/b4temp.c index 63df154d0..8c0174623 100644 --- a/src/spicelib/devices/bsim4/b4temp.c +++ b/src/spicelib/devices/bsim4/b4temp.c @@ -409,8 +409,7 @@ int Size_Not_Found, i; Wdrn = here->BSIM4w / here->BSIM4nf; if (Size_Not_Found) - { pParam = (struct bsim4SizeDependParam *)tmalloc( - sizeof(struct bsim4SizeDependParam)); + { pParam = TMALLOC(struct bsim4SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim4v2/b4v2noi.c b/src/spicelib/devices/bsim4v2/b4v2noi.c index b8784791f..32fa95164 100644 --- a/src/spicelib/devices/bsim4v2/b4v2noi.c +++ b/src/spicelib/devices/bsim4v2/b4v2noi.c @@ -129,10 +129,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM4v2name, BSIM4v2nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -147,10 +144,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM4v2name, BSIM4v2nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -162,10 +156,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM4v2name, BSIM4v2nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim4v2/b4v2temp.c b/src/spicelib/devices/bsim4v2/b4v2temp.c index 93c45ef53..f48a05692 100644 --- a/src/spicelib/devices/bsim4v2/b4v2temp.c +++ b/src/spicelib/devices/bsim4v2/b4v2temp.c @@ -339,8 +339,7 @@ int Size_Not_Found; } if (Size_Not_Found) - { pParam = (struct bsim4SizeDependParam *)tmalloc( - sizeof(struct bsim4SizeDependParam)); + { pParam = TMALLOC(struct bsim4SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim4v3/b4v3noi.c b/src/spicelib/devices/bsim4v3/b4v3noi.c index 9733d1710..936f1bdea 100644 --- a/src/spicelib/devices/bsim4v3/b4v3noi.c +++ b/src/spicelib/devices/bsim4v3/b4v3noi.c @@ -131,10 +131,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM4v3name, BSIM4v3nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -149,10 +146,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM4v3name, BSIM4v3nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -164,10 +158,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM4v3name, BSIM4v3nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim4v3/b4v3temp.c b/src/spicelib/devices/bsim4v3/b4v3temp.c index f8a716bfa..fca472681 100644 --- a/src/spicelib/devices/bsim4v3/b4v3temp.c +++ b/src/spicelib/devices/bsim4v3/b4v3temp.c @@ -347,8 +347,7 @@ int Size_Not_Found, i; Ldrn = here->BSIM4v3l; if (Size_Not_Found) - { pParam = (struct bsim4v3SizeDependParam *)tmalloc( - sizeof(struct bsim4v3SizeDependParam)); + { pParam = TMALLOC(struct bsim4v3SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim4v4/b4v4noi.c b/src/spicelib/devices/bsim4v4/b4v4noi.c index 1d40b9815..0471026c3 100644 --- a/src/spicelib/devices/bsim4v4/b4v4noi.c +++ b/src/spicelib/devices/bsim4v4/b4v4noi.c @@ -132,10 +132,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM4v4name, BSIM4v4nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -150,10 +147,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM4v4name, BSIM4v4nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -165,10 +159,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM4v4name, BSIM4v4nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim4v4/b4v4temp.c b/src/spicelib/devices/bsim4v4/b4v4temp.c index 47e351c74..568a607bb 100644 --- a/src/spicelib/devices/bsim4v4/b4v4temp.c +++ b/src/spicelib/devices/bsim4v4/b4v4temp.c @@ -357,8 +357,7 @@ int Size_Not_Found, i; Ldrn = here->BSIM4v4l; if (Size_Not_Found) - { pParam = (struct bsim4SizeDependParam *)tmalloc( - sizeof(struct bsim4SizeDependParam)); + { pParam = TMALLOC(struct bsim4SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim4v5/b4v5noi.c b/src/spicelib/devices/bsim4v5/b4v5noi.c index a30a70da6..95a15ea5d 100644 --- a/src/spicelib/devices/bsim4v5/b4v5noi.c +++ b/src/spicelib/devices/bsim4v5/b4v5noi.c @@ -134,10 +134,7 @@ int i; { (void) sprintf(name, "onoise.%s%s", here->BSIM4v5name, BSIM4v5nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -152,10 +149,7 @@ int i; { (void) sprintf(name, "onoise_total.%s%s", here->BSIM4v5name, BSIM4v5nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, @@ -167,10 +161,7 @@ int i; (void) sprintf(name, "inoise_total.%s%s", here->BSIM4v5name, BSIM4v5nNames[i]); - data->namelist = (IFuid *) trealloc( - (char *) data->namelist, - (data->numPlots + 1) - * sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) (ckt, diff --git a/src/spicelib/devices/bsim4v5/b4v5temp.c b/src/spicelib/devices/bsim4v5/b4v5temp.c index 6a162f329..e3ae39e70 100644 --- a/src/spicelib/devices/bsim4v5/b4v5temp.c +++ b/src/spicelib/devices/bsim4v5/b4v5temp.c @@ -361,8 +361,7 @@ int Size_Not_Found, i; Wdrn = here->BSIM4v5w / here->BSIM4v5nf; if (Size_Not_Found) - { pParam = (struct bsim4v5SizeDependParam *)tmalloc( - sizeof(struct bsim4v5SizeDependParam)); + { pParam = TMALLOC(struct bsim4v5SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/cap/capask.c b/src/spicelib/devices/cap/capask.c index 4af671504..b86768592 100644 --- a/src/spicelib/devices/cap/capask.c +++ b/src/spicelib/devices/cap/capask.c @@ -53,7 +53,7 @@ CAPask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case CAP_CURRENT: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "CAPask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -72,7 +72,7 @@ CAPask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case CAP_POWER: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "CAPask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/cccs/cccsask.c b/src/spicelib/devices/cccs/cccsask.c index c06846af6..f5569d9e8 100644 --- a/src/spicelib/devices/cccs/cccsask.c +++ b/src/spicelib/devices/cccs/cccsask.c @@ -47,7 +47,7 @@ CCCSask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return (OK); case CCCS_CURRENT : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "CCCSask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -62,7 +62,7 @@ CCCSask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return(OK); case CCCS_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "CCCSask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/ccvs/ccvsask.c b/src/spicelib/devices/ccvs/ccvsask.c index 4bdf880a7..b9b0744db 100644 --- a/src/spicelib/devices/ccvs/ccvsask.c +++ b/src/spicelib/devices/ccvs/ccvsask.c @@ -48,7 +48,7 @@ CCVSask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return (OK); case CCVS_CURRENT : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "CCVSask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -62,7 +62,7 @@ CCVSask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return(OK); case CCVS_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "CCVSask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/cktinit.c b/src/spicelib/devices/cktinit.c index 2ad3f8a59..8970e7759 100644 --- a/src/spicelib/devices/cktinit.c +++ b/src/spicelib/devices/cktinit.c @@ -24,14 +24,14 @@ int CKTinit(CKTcircuit **ckt) /* new circuit to create */ { int i; - CKTcircuit *sckt = (CKTcircuit *) tmalloc(sizeof(CKTcircuit)); + CKTcircuit *sckt = TMALLOC(CKTcircuit, 1); *ckt = sckt; if (sckt == NULL) return(E_NOMEM); /* gtri - begin - dynamically allocate the array of model lists */ /* CKThead used to be statically sized in CKTdefs.h, but has been changed */ /* to a ** pointer */ - (sckt)->CKThead = (GENmodel **)tmalloc(DEVmaxnum * sizeof(GENmodel *)); + (sckt)->CKThead = TMALLOC(GENmodel *, DEVmaxnum); if((sckt)->CKThead == NULL) return(E_NOMEM); /* gtri - end - dynamically allocate the array of model lists */ @@ -74,7 +74,7 @@ CKTinit(CKTcircuit **ckt) /* new circuit to create */ sckt->CKTdefaultMosAS = 0; sckt->CKTsrcFact=1; sckt->CKTdiagGmin=0; - sckt->CKTstat = (STATistics *) tmalloc(sizeof(STATistics)); + sckt->CKTstat = TMALLOC(STATistics, 1); sckt->CKTtroubleNode = 0; sckt->CKTtroubleElt = NULL; sckt->CKTtimePoints = NULL; @@ -89,7 +89,7 @@ CKTinit(CKTcircuit **ckt) /* new circuit to create */ /* gtri - begin - wbk - allocate/initialize substructs */ /* Allocate evt data structure */ - (sckt)->evt = (Evt_Ckt_Data_t *) MALLOC(sizeof(Evt_Ckt_Data_t)); + (sckt)->evt = TMALLOC(Evt_Ckt_Data_t, 1); if(! (sckt)->evt) return(E_NOMEM); @@ -97,7 +97,7 @@ CKTinit(CKTcircuit **ckt) /* new circuit to create */ (sckt)->evt->options.op_alternate = MIF_TRUE; /* Allocate enh data structure */ - (sckt)->enh = (Enh_Ckt_Data_t *) MALLOC(sizeof(Enh_Ckt_Data_t)); + (sckt)->enh = TMALLOC(Enh_Ckt_Data_t, 1); if(! (sckt)->enh) return(E_NOMEM); diff --git a/src/spicelib/devices/cpl/cplload.c b/src/spicelib/devices/cpl/cplload.c index 2f3bfccfb..9c78b0441 100644 --- a/src/spicelib/devices/cpl/cplload.c +++ b/src/spicelib/devices/cpl/cplload.c @@ -339,7 +339,7 @@ copy_cp(CPLine *new, CPLine *old) for (j = 0; j < m; j++) { if (new->h1t[i][j] == NULL) - new->h1t[i][j] = (TMS *) tmalloc(sizeof (TMS)); + new->h1t[i][j] = TMALLOC(TMS, 1); new->h1t[i][j]->ifImg = old->h1t[i][j]->ifImg; new->h1t[i][j]->aten = old->h1t[i][j]->aten; new->h1C[i][j] = old->h1C[i][j]; @@ -353,7 +353,7 @@ copy_cp(CPLine *new, CPLine *old) } for (l = 0; l < m; l++) { if (new->h2t[i][j][l] == NULL) - new->h2t[i][j][l] = (TMS *) tmalloc(sizeof (TMS)); + new->h2t[i][j][l] = TMALLOC(TMS, 1); new->h2t[i][j][l]->ifImg = old->h2t[i][j][l]->ifImg; new->h2t[i][j][l]->aten = old->h2t[i][j][l]->aten; new->h2C[i][j][l] = old->h2C[i][j][l]; @@ -368,7 +368,7 @@ copy_cp(CPLine *new, CPLine *old) } if (new->h3t[i][j][l] == NULL) - new->h3t[i][j][l] = (TMS *) tmalloc(sizeof (TMS)); + new->h3t[i][j][l] = TMALLOC(TMS, 1); new->h3t[i][j][l]->ifImg = old->h3t[i][j][l]->ifImg; new->h3t[i][j][l]->aten = old->h3t[i][j][l]->aten; for (k = 0; k < 3; k++) { @@ -622,7 +622,7 @@ static VI_list q = pool_vi; pool_vi = pool_vi->pool; return(q); - } else return((VI_list *) tmalloc (sizeof (VI_list))); + } else return(TMALLOC(VI_list, 1)); } static void diff --git a/src/spicelib/devices/cpl/cplsetup.c b/src/spicelib/devices/cpl/cplsetup.c index b5c0e3e16..03eb80575 100644 --- a/src/spicelib/devices/cpl/cplsetup.c +++ b/src/spicelib/devices/cpl/cplsetup.c @@ -18,12 +18,12 @@ Modified: 2004 Paolo Nenzi - (ng)spice integration #define VECTOR_ALLOC(vec, n) { \ - vec = (double **) tmalloc(n * sizeof(double *)); \ + vec = TMALLOC(double *, n); \ } #define MATRIX_ALLOC(mat, m, j) { \ int k; \ - mat = (double ***) tmalloc(m * sizeof(double **)); \ + mat = TMALLOC(double **, m); \ for (k = 0; k < m; k++) { \ VECTOR_ALLOC(mat[k], j); \ } \ @@ -190,10 +190,10 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\ noL = here->dimension; - here->CPLposNodes = (int *) tmalloc(noL * sizeof(int)); - here->CPLnegNodes = (int *) tmalloc(noL * sizeof(int)); - here->CPLibr1 = (int *) tmalloc(noL * sizeof(int)); - here->CPLibr2 = (int *) tmalloc(noL * sizeof(int)); + here->CPLposNodes = TMALLOC(int, noL); + here->CPLnegNodes = TMALLOC(int, noL); + here->CPLibr1 = TMALLOC(int, noL); + here->CPLibr2 = TMALLOC(int, noL); VECTOR_ALLOC(here->CPLibr1Ibr1, noL); VECTOR_ALLOC(here->CPLibr2Ibr2, noL); @@ -212,10 +212,10 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\ MATRIX_ALLOC(here->CPLibr2Ibr1, noL, noL); - branchname = (char **) tmalloc(sizeof(char *) * here->dimension); + branchname = TMALLOC(char *, here->dimension); if (! here->CPLibr1Given) { for (m = 0; m < here->dimension; m++) { - branchname[m] = (char*) tmalloc(MAX_STRING); + branchname[m] = TMALLOC(char, MAX_STRING); sprintf(branchname[m], "branch1_%d", m); error = CKTmkCur(ckt, &tmp, here->CPLname, branchname[m]); @@ -225,10 +225,10 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\ here->CPLibr1Given = 1; } free(branchname); - branchname = (char **) tmalloc(sizeof(char *) * here->dimension); + branchname = TMALLOC(char *, here->dimension); if (! here->CPLibr2Given) { for (m = 0; m < here->dimension; m++) { - branchname[m] = (char*) tmalloc(MAX_STRING); + branchname[m] = TMALLOC(char, MAX_STRING); sprintf(branchname[m], "branch2_%d", m); error = CKTmkCur(ckt, &tmp, here->CPLname, branchname[m]); @@ -363,15 +363,15 @@ ReadCpL(CPLinstance *here, CKTcircuit *ckt) RLINE *lines[MAX_CP_TX_LINES]; ERLINE *er; - c = (CPLine *) tmalloc(sizeof (CPLine)); - c2 = (CPLine *) tmalloc(sizeof (CPLine)); + c = TMALLOC(CPLine, 1); + c2 = TMALLOC(CPLine, 1); c->vi_head = c->vi_tail = NULL; noL = c->noL = here->dimension; here->cplines = c; here->cplines2 = c2; for (i = 0; i < noL; i++) { - ec = (ECPLine *) tmalloc(sizeof (ECPLine)); + ec = TMALLOC(ECPLine, 1); name = here->in_node_names[i]; nd = insert_node(name); ec->link = nd->cplptr; @@ -380,17 +380,17 @@ ReadCpL(CPLinstance *here, CKTcircuit *ckt) c->in_node[i] = nd; c2->in_node[i] = nd; - er = (ERLINE *) tmalloc(sizeof (ERLINE)); + er = TMALLOC(ERLINE, 1); er->link = nd->rlptr; nd->rlptr = er; - er->rl = lines[i] = (RLINE *) tmalloc(sizeof (RLINE)); + er->rl = lines[i] = TMALLOC(RLINE, 1); er->rl->in_node = nd; c->dc1[i] = c->dc2[i] = 0.0; } for (i = 0; i < noL; i++) { - ec = (ECPLine *) tmalloc(sizeof (ECPLine)); + ec = TMALLOC(ECPLine, 1); name = here->out_node_names[i]; nd = insert_node(name); ec->link = nd->cplptr; @@ -399,7 +399,7 @@ ReadCpL(CPLinstance *here, CKTcircuit *ckt) c->out_node[i] = nd; c2->out_node[i] = nd; - er = (ERLINE *) tmalloc(sizeof (ERLINE)); + er = TMALLOC(ERLINE, 1); er->link = nd->rlptr; nd->rlptr = er; er->rl = lines[i]; @@ -444,7 +444,7 @@ ReadCpL(CPLinstance *here, CKTcircuit *ckt) if (SIV[i][j].C_0 == 0.0) c->h1t[i][j] = NULL; else { - c->h1t[i][j] = (TMS *) tmalloc(sizeof (TMS)); + c->h1t[i][j] = TMALLOC(TMS, 1); d = c->h1t[i][j]->aten = SIV[i][j].C_0; c->h1t[i][j]->ifImg = (int) (SIV[i][j].Poly[6] - 1.0); /* since originally 2 for img 1 for noimg */ @@ -468,7 +468,7 @@ ReadCpL(CPLinstance *here, CKTcircuit *ckt) if (IWI[i][j].C_0[k] == 0.0) c->h2t[i][j][k] = NULL; else { - c->h2t[i][j][k] = (TMS *) tmalloc(sizeof (TMS)); + c->h2t[i][j][k] = TMALLOC(TMS, 1); d = c->h2t[i][j][k]->aten = IWI[i][j].C_0[k]; c->h2t[i][j][k]->ifImg = (int) (IWI[i][j].Poly[k][6] - 1.0); /* since originally 2 for img 1 for noimg */ @@ -489,7 +489,7 @@ ReadCpL(CPLinstance *here, CKTcircuit *ckt) if (IWV[i][j].C_0[k] == 0.0) c->h3t[i][j][k] = NULL; else { - c->h3t[i][j][k] = (TMS *) tmalloc(sizeof (TMS)); + c->h3t[i][j][k] = TMALLOC(TMS, 1); d = c->h3t[i][j][k]->aten = IWV[i][j].C_0[k]; c->h3t[i][j][k]->ifImg = (int) (IWV[i][j].Poly[k][6] - 1.0); /* since originally 2 for img 1 for noimg */ @@ -513,7 +513,7 @@ ReadCpL(CPLinstance *here, CKTcircuit *ckt) for (i = 0; i < noL; i++) { if (c->taul[i] < ckt->CKTmaxStep) { - errMsg = (char*) tmalloc(strlen(message)+1); + errMsg = TMALLOC(char, strlen(message) + 1); strcpy(errMsg,message); return(-1); } @@ -567,7 +567,7 @@ static double { double *v; - v = (double *) tmalloc((unsigned) (nh - nl +1) * sizeof(double)); + v = TMALLOC(double, (unsigned) (nh - nl + 1)); if (!v) { fprintf(stderr, "Memory Allocation Error by tmalloc in vector().\n"); fprintf(stderr, "...now exiting to system ...\n"); @@ -1844,7 +1844,7 @@ insert_ND(char *name, NDnamePt *ndn) NDnamePt p; if (*ndn == NULL) { - p = *ndn = (NDname*) tmalloc(sizeof (NDname)); + p = *ndn = TMALLOC(NDname, 1); p->nd = NULL; p->right = p->left = NULL; strcpy(p->id, name); @@ -1896,7 +1896,7 @@ static NODE { NODE *n; - n = (NODE *) tmalloc (sizeof (NODE)); + n = TMALLOC(NODE, 1); n->mptr = NULL; n->gptr = NULL; n->cptr = NULL; @@ -1963,7 +1963,7 @@ ordering(void) mv = ABS(ZY[i][j]); m = j; } - e = (MAXE*) tmalloc(sizeof (MAXE)); + e = TMALLOC(MAXE, 1); row = sort(row, mv, i, m, e); } } diff --git a/src/spicelib/devices/csw/cswask.c b/src/spicelib/devices/csw/cswask.c index 4b33f4e85..f56c1a76b 100644 --- a/src/spicelib/devices/csw/cswask.c +++ b/src/spicelib/devices/csw/cswask.c @@ -37,7 +37,7 @@ CSWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *s return (OK); case CSW_CURRENT: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "CSWask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -49,7 +49,7 @@ CSWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *s return(OK); case CSW_POWER: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "CSWask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/csw/cswnoise.c b/src/spicelib/devices/csw/cswnoise.c index 4244bc3c9..7c3f3d7ef 100644 --- a/src/spicelib/devices/csw/cswnoise.c +++ b/src/spicelib/devices/csw/cswnoise.c @@ -53,7 +53,7 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d (void)sprintf(name,"onoise_%s",inst->CSWname); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -65,7 +65,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s",inst->CSWname); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -75,7 +75,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s",inst->CSWname); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/dev.c b/src/spicelib/devices/dev.c index 0dcffb843..b4040224c 100644 --- a/src/spicelib/devices/dev.c +++ b/src/spicelib/devices/dev.c @@ -173,15 +173,15 @@ spice_init_devices(void) { #ifdef XSPICE /*Initilise the structs and add digital node type */ - g_evt_udn_info = (Evt_Udn_Info_t **)MALLOC(sizeof(Evt_Udn_Info_t *)); + g_evt_udn_info = TMALLOC(Evt_Udn_Info_t *, 1); g_evt_num_udn_types = 1; g_evt_udn_info[0] = &idn_digital_info; - DEVicesfl = (int *)tmalloc(DEVNUM*sizeof(int)); + DEVicesfl = TMALLOC(int, DEVNUM); /* tmalloc should automatically zero the array! */ #endif - DEVices = (SPICEdev **)tmalloc(DEVNUM*sizeof(SPICEdev *)); + DEVices = TMALLOC(SPICEdev *, DEVNUM); /* URC device MUST precede both resistors and capacitors */ DEVices[ 0] = get_urc_info(); DEVices[ 1] = get_asrc_info(); @@ -371,8 +371,8 @@ static void relink(void) { int add_device(int n, SPICEdev **devs, int flag){ int i; - DEVices = (SPICEdev **)trealloc(DEVices,(DEVNUM+n)*sizeof(SPICEdev *)); - DEVicesfl = (int *)trealloc(DEVicesfl,(DEVNUM+n)*sizeof(int)); + DEVices = TREALLOC(SPICEdev *, DEVices, DEVNUM + n); + DEVicesfl = TREALLOC(int, DEVicesfl, DEVNUM + n); for(i = 0; i < n;i++){ #ifdef TRACE printf("Added device: %s\n",devs[i]->DEVpublic.name); @@ -391,7 +391,7 @@ int add_device(int n, SPICEdev **devs, int flag){ int add_udn(int n,Evt_Udn_Info_t **udns){ int i; - g_evt_udn_info = (Evt_Udn_Info_t **)trealloc(g_evt_udn_info,(g_evt_num_udn_types+n)*sizeof(Evt_Udn_Info_t *)); + g_evt_udn_info = TREALLOC(Evt_Udn_Info_t *, g_evt_udn_info, g_evt_num_udn_types + n); for(i = 0; i < n;i++){ #ifdef TRACE printf("Added udn: %s\n",udns[i]->name); diff --git a/src/spicelib/devices/dio/dioask.c b/src/spicelib/devices/dio/dioask.c index b99ab0a6d..223219667 100644 --- a/src/spicelib/devices/dio/dioask.c +++ b/src/spicelib/devices/dio/dioask.c @@ -69,7 +69,7 @@ DIOask (CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case DIO_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "DIOask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/dio/dionoise.c b/src/spicelib/devices/dio/dionoise.c index 9329bbf0e..f8f9d23a9 100644 --- a/src/spicelib/devices/dio/dionoise.c +++ b/src/spicelib/devices/dio/dionoise.c @@ -63,7 +63,7 @@ DIOnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, for (i=0; i < DIONSRCS; i++) { (void)sprintf(name,"onoise_%s%s",inst->DIOname,DIOnNames[i]); - data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), (IFuid)NULL, name, UID_OTHER, NULL); @@ -76,7 +76,7 @@ DIOnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, for (i=0; i < DIONSRCS; i++) { (void)sprintf(name,"onoise_total_%s%s",inst->DIOname,DIOnNames[i]); - data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), (IFuid)NULL, name, UID_OTHER, NULL); @@ -84,7 +84,7 @@ DIOnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"inoise_total_%s%s",inst->DIOname,DIOnNames[i]); - data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), (IFuid)NULL, name, UID_OTHER, NULL); diff --git a/src/spicelib/devices/dio/diosset.c b/src/spicelib/devices/dio/diosset.c index bb0a60d4c..ded0b9b34 100644 --- a/src/spicelib/devices/dio/diosset.c +++ b/src/spicelib/devices/dio/diosset.c @@ -37,7 +37,7 @@ DIOsSetup(SENstruct *info, GENmodel *inModel) here->DIOsenParmNo = ++(info->SENparms); here->DIOsenPertFlag = OFF; } - if((here->DIOsens = (double *)MALLOC(7*sizeof(double))) + if((here->DIOsens = TMALLOC(double, 7)) == NULL) return(E_NOMEM); } diff --git a/src/spicelib/devices/dio/diotemp.c b/src/spicelib/devices/dio/diotemp.c index 4998717e6..d8b98e729 100644 --- a/src/spicelib/devices/dio/diotemp.c +++ b/src/spicelib/devices/dio/diotemp.c @@ -171,7 +171,7 @@ DIOtemp(GENmodel *inModel, CKTcircuit *ckt) model->DIObreakdownVoltage/vt) { cbv=here->DIOtSatCur*here->DIOarea*here->DIOm * model->DIObreakdownVoltage/vt; - emsg = (char*) MALLOC(100); + emsg = TMALLOC(char, 100); if(emsg == (char *)NULL) return(E_NOMEM); (void)sprintf(emsg, "%%s: breakdown current increased to %g to resolve", @@ -193,7 +193,7 @@ DIOtemp(GENmodel *inModel, CKTcircuit *ckt) (exp((model->DIObreakdownVoltage-xbv)/vt)-1+xbv/vt); if (fabs(xcbv-cbv) <= tol) goto matched; } - emsg = (char*) MALLOC(100); + emsg = TMALLOC(char, 100); if(emsg == (char *)NULL) return(E_NOMEM); (void)sprintf(emsg, "%%s: unable to match forward and reverse diode regions: bv = %g, ibv = %g", diff --git a/src/spicelib/devices/hfet1/hfetask.c b/src/spicelib/devices/hfet1/hfetask.c index 01d9ad5e1..0110e0219 100644 --- a/src/spicelib/devices/hfet1/hfetask.c +++ b/src/spicelib/devices/hfet1/hfetask.c @@ -114,7 +114,7 @@ HFETAask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue return (OK); case HFETA_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "HFETAask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -126,7 +126,7 @@ HFETAask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue return(OK); case HFETA_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "HFETAask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/hfet2/hfet2ask.c b/src/spicelib/devices/hfet2/hfet2ask.c index 3ec5d8a5d..f7a0976ca 100644 --- a/src/spicelib/devices/hfet2/hfet2ask.c +++ b/src/spicelib/devices/hfet2/hfet2ask.c @@ -109,7 +109,7 @@ HFET2ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return (OK); case HFET2_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "HFET2ask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -121,7 +121,7 @@ HFET2ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case HFET2_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "HFET2ask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/hisim/hsm1noi.c b/src/spicelib/devices/hisim/hsm1noi.c index 0368972af..c91f3a357 100644 --- a/src/spicelib/devices/hisim/hsm1noi.c +++ b/src/spicelib/devices/hisim/hsm1noi.c @@ -91,8 +91,7 @@ HSM1noise (int mode, int operation, GENmodel *inModel, CKTcircuit *ckt, (void) sprintf(name, "onoise.%s%s", (char *)here->HSM1name, HSM1nNames[i]); data->namelist = - (IFuid *) trealloc((char *) data->namelist, - (data->numPlots + 1) * sizeof(IFuid)); + TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) @@ -105,8 +104,7 @@ HSM1noise (int mode, int operation, GENmodel *inModel, CKTcircuit *ckt, (void) sprintf(name, "onoise_total.%s%s", (char *)here->HSM1name, HSM1nNames[i]); data->namelist = - (IFuid *) trealloc((char *) data->namelist, - (data->numPlots + 1) * sizeof(IFuid)); + TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) @@ -116,8 +114,7 @@ HSM1noise (int mode, int operation, GENmodel *inModel, CKTcircuit *ckt, (void) sprintf(name, "inoise_total.%s%s", (char *)here->HSM1name, HSM1nNames[i]); data->namelist = - (IFuid *) trealloc((char *) data->namelist, - (data->numPlots + 1) * sizeof(IFuid)); + TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid)) diff --git a/src/spicelib/devices/ind/indask.c b/src/spicelib/devices/ind/indask.c index 86a1af322..43427dd60 100644 --- a/src/spicelib/devices/ind/indask.c +++ b/src/spicelib/devices/ind/indask.c @@ -52,7 +52,7 @@ INDask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case IND_CURRENT : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "INDask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -62,7 +62,7 @@ INDask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case IND_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "INDask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/isrc/isrcask.c b/src/spicelib/devices/isrc/isrcask.c index d9f74466e..c8eeff788 100644 --- a/src/spicelib/devices/isrc/isrcask.c +++ b/src/spicelib/devices/isrc/isrcask.c @@ -46,8 +46,7 @@ ISRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * case ISRC_AM: case ISRC_FCN_COEFFS: temp = value->v.numValue = here->ISRCfunctionOrder; - value->v.vec.rVec = (double *) - MALLOC(here->ISRCfunctionOrder * sizeof(double)); + value->v.vec.rVec = TMALLOC(double, here->ISRCfunctionOrder); v = value->v.vec.rVec; w = here->ISRCcoeffs; while (temp--) @@ -76,7 +75,7 @@ ISRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return(OK); case ISRC_POWER: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "ISRCask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/jfet/jfetask.c b/src/spicelib/devices/jfet/jfetask.c index 6af9f47b5..f479d421f 100644 --- a/src/spicelib/devices/jfet/jfetask.c +++ b/src/spicelib/devices/jfet/jfetask.c @@ -112,7 +112,7 @@ JFETask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case JFET_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "JFETask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -124,7 +124,7 @@ JFETask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case JFET_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "JFETask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/jfet/jfetnoi.c b/src/spicelib/devices/jfet/jfetnoi.c index 873dd2d4a..351c6ae98 100644 --- a/src/spicelib/devices/jfet/jfetnoi.c +++ b/src/spicelib/devices/jfet/jfetnoi.c @@ -63,7 +63,7 @@ JFETnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata * (void)sprintf(name,"onoise_%s%s",inst->JFETname,JFETnNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -79,7 +79,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s%s",inst->JFETname,JFETnNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -90,7 +90,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s%s",inst->JFETname,JFETnNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/jfet2/jfet2ask.c b/src/spicelib/devices/jfet2/jfet2ask.c index 7df770b49..2e01e5dc8 100644 --- a/src/spicelib/devices/jfet2/jfet2ask.c +++ b/src/spicelib/devices/jfet2/jfet2ask.c @@ -121,7 +121,7 @@ JFET2ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case JFET2_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "JFET2ask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -133,7 +133,7 @@ JFET2ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case JFET2_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "JFET2ask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/jfet2/jfet2noi.c b/src/spicelib/devices/jfet2/jfet2noi.c index c38767677..1c9cafa9a 100644 --- a/src/spicelib/devices/jfet2/jfet2noi.c +++ b/src/spicelib/devices/jfet2/jfet2noi.c @@ -68,7 +68,7 @@ JFET2noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata (void)sprintf(name,"onoise_%s%s",inst->JFET2name,JFET2nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -84,7 +84,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s%s",inst->JFET2name,JFET2nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -95,7 +95,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s%s",inst->JFET2name,JFET2nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/ltra/ltraacct.c b/src/spicelib/devices/ltra/ltraacct.c index b8ecf0ff6..c6ee9e34a 100644 --- a/src/spicelib/devices/ltra/ltraacct.c +++ b/src/spicelib/devices/ltra/ltraacct.c @@ -28,7 +28,7 @@ LTRAaccept(CKTcircuit *ckt, GENmodel *inModel) #define LTRAmemMANAGE(a,b) \ if ( a != NULL) FREE(a);\ - a = (double *) MALLOC( b * sizeof(double)); + a = TMALLOC(double, b); model->LTRAmodelListSize = 10; @@ -41,15 +41,9 @@ LTRAaccept(CKTcircuit *ckt, GENmodel *inModel) model->LTRAmodelListSize += ckt->CKTsizeIncr; - model->LTRAh1dashCoeffs = (double *) - REALLOC((char *) model->LTRAh1dashCoeffs, - sizeof(double) * model->LTRAmodelListSize); - model->LTRAh2Coeffs = (double *) - REALLOC((char *) model->LTRAh2Coeffs, - sizeof(double) * model->LTRAmodelListSize); - model->LTRAh3dashCoeffs = (double *) - REALLOC((char *) model->LTRAh3dashCoeffs, - sizeof(double) * model->LTRAmodelListSize); + model->LTRAh1dashCoeffs = TREALLOC(double, model->LTRAh1dashCoeffs, model->LTRAmodelListSize); + model->LTRAh2Coeffs = TREALLOC(double, model->LTRAh2Coeffs, model->LTRAmodelListSize); + model->LTRAh3dashCoeffs = TREALLOC(double, model->LTRAh3dashCoeffs, model->LTRAmodelListSize); } /* loop through all the instances of the model */ for (here = model->LTRAinstances; here != NULL; @@ -74,14 +68,10 @@ LTRAaccept(CKTcircuit *ckt, GENmodel *inModel) if (ckt->CKTtimeIndex >= here->LTRAinstListSize) { /* need more space */ here->LTRAinstListSize += ckt->CKTsizeIncr; - here->LTRAv1 = (double *) REALLOC((char *) - here->LTRAv1, sizeof(double) * (here->LTRAinstListSize)); - here->LTRAi1 = (double *) REALLOC((char *) - here->LTRAi1, sizeof(double) * (here->LTRAinstListSize)); - here->LTRAi2 = (double *) REALLOC((char *) - here->LTRAi2, sizeof(double) * (here->LTRAinstListSize)); - here->LTRAv2 = (double *) REALLOC((char *) - here->LTRAv2, sizeof(double) * (here->LTRAinstListSize)); + here->LTRAv1 = TREALLOC(double, here->LTRAv1, here->LTRAinstListSize); + here->LTRAi1 = TREALLOC(double, here->LTRAi1, here->LTRAinstListSize); + here->LTRAi2 = TREALLOC(double, here->LTRAi2, here->LTRAinstListSize); + here->LTRAv2 = TREALLOC(double, here->LTRAv2, here->LTRAinstListSize); } *(here->LTRAv1 + ckt->CKTtimeIndex) = *(ckt->CKTrhsOld + here->LTRAposNode1) - *(ckt->CKTrhsOld + diff --git a/src/spicelib/devices/ltra/ltraask.c b/src/spicelib/devices/ltra/ltraask.c index 384dcb133..50b7cf882 100644 --- a/src/spicelib/devices/ltra/ltraask.c +++ b/src/spicelib/devices/ltra/ltraask.c @@ -73,7 +73,7 @@ LTRAask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return (OK); case LTRA_DELAY: /* - * value->v.vec.rVec = (double *) MALLOC(here->LTRAsizeDelay * sizeof(double)); + * value->v.vec.rVec = TMALLOC(double, here->LTRAsizeDelay); * value->v.numValue = temp = here->LTRAsizeDelay; while (temp--) { * value->v.vec.rVec++ = *here->LTRAdelays++; */ diff --git a/src/spicelib/devices/ltra/ltramisc.c b/src/spicelib/devices/ltra/ltramisc.c index 5c7c47be3..a2c3d8708 100644 --- a/src/spicelib/devices/ltra/ltramisc.c +++ b/src/spicelib/devices/ltra/ltramisc.c @@ -1360,8 +1360,8 @@ LTRAlteCalculate(CKTcircuit *ckt, GENmodel *genmodel, GENinstance *geninstance, * * { double *dtime, *diffs, returnval; int i,j; * - * diffs = (double *) MALLOC(sizeof(double) * (timeindex+2)); - * dtime = (double *) MALLOC(sizeof(double) * (timeindex+2)); + * diffs = TMALLOC(double, timeindex + 2); + * dtime = TMALLOC(double, timeindex + 2); */ /* now divided differences */ @@ -1403,10 +1403,10 @@ LTRAlteCalculate(CKTcircuit *ckt, GENmodel *genmodel, GENinstance *geninstance, * * if (curtime > model->LTRAtd) { tdover = 1; } else { tdover = 0; } * - * h1dashTcoeffs = (double *) MALLOC(sizeof(double) * model->LTRAmodelListSize); - * h2Tcoeffs = (double *) MALLOC(sizeof(double) * model->LTRAmodelListSize); - * h3dashTcoeffs = (double *) MALLOC(sizeof(double) * model->LTRAmodelListSize); - * SecondDerivs = (double *) MALLOC(sizeof(double) * model->LTRAmodelListSize); + * h1dashTcoeffs = TMALLOC(double, model->LTRAmodelListSize); + * h2Tcoeffs = TMALLOC(double, model->LTRAmodelListSize); + * h3dashTcoeffs = TMALLOC(double, model->LTRAmodelListSize); + * SecondDerivs = TMALLOC(double, model->LTRAmodelListSize); * */ diff --git a/src/spicelib/devices/mes/mesask.c b/src/spicelib/devices/mes/mesask.c index d63522f0d..e96a40d04 100644 --- a/src/spicelib/devices/mes/mesask.c +++ b/src/spicelib/devices/mes/mesask.c @@ -98,7 +98,7 @@ MESask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *s return (OK); case MES_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MESask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -110,7 +110,7 @@ MESask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *s return(OK); case MES_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MESask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/mes/mesnoise.c b/src/spicelib/devices/mes/mesnoise.c index 8fe8162be..ad4374e3d 100644 --- a/src/spicelib/devices/mes/mesnoise.c +++ b/src/spicelib/devices/mes/mesnoise.c @@ -63,7 +63,7 @@ MESnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d (void)sprintf(name,"onoise_%s%s",inst->MESname,MESnNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -79,7 +79,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s%s",inst->MESname,MESnNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -94,7 +94,7 @@ if (!data->namelist) return(E_NOMEM); data->numPlots += 2; */ -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/mesa/mesaask.c b/src/spicelib/devices/mesa/mesaask.c index 3f319f096..10f4ed1f1 100644 --- a/src/spicelib/devices/mesa/mesaask.c +++ b/src/spicelib/devices/mesa/mesaask.c @@ -120,7 +120,7 @@ MESAask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return (OK); case MESA_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MESAask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -132,7 +132,7 @@ MESAask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return(OK); case MESA_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MESAask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/mos1/mos1ask.c b/src/spicelib/devices/mos1/mos1ask.c index 9810c8553..81780807a 100644 --- a/src/spicelib/devices/mos1/mos1ask.c +++ b/src/spicelib/devices/mos1/mos1ask.c @@ -353,7 +353,7 @@ MOS1ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS1_CB : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS1ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -364,7 +364,7 @@ MOS1ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS1_CG : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS1ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -381,7 +381,7 @@ MOS1ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS1_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS1ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -399,7 +399,7 @@ MOS1ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS1_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS1ask.c"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/mos1/mos1noi.c b/src/spicelib/devices/mos1/mos1noi.c index e8013400b..77410bf6c 100644 --- a/src/spicelib/devices/mos1/mos1noi.c +++ b/src/spicelib/devices/mos1/mos1noi.c @@ -74,7 +74,7 @@ MOS1noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, for (i=0; i < MOS1NSRCS; i++) { (void)sprintf(name,"onoise_%s%s",inst->MOS1name,MOS1nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -90,7 +90,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s%s",inst->MOS1name,MOS1nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -101,7 +101,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s%s",inst->MOS1name,MOS1nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/mos1/mos1sset.c b/src/spicelib/devices/mos1/mos1sset.c index 00ee12c50..e61470fb3 100644 --- a/src/spicelib/devices/mos1/mos1sset.c +++ b/src/spicelib/devices/mos1/mos1sset.c @@ -38,7 +38,7 @@ MOS1sSetup(SENstruct *info, GENmodel *inModel) here->MOS1senParmNo = ++(info->SENparms); } } - if((here->MOS1sens = (double *)MALLOC(70*sizeof(double))) == NULL) { + if((here->MOS1sens = TMALLOC(double, 70)) == NULL) { return(E_NOMEM); } here->MOS1senPertFlag = OFF; diff --git a/src/spicelib/devices/mos2/mos2ask.c b/src/spicelib/devices/mos2/mos2ask.c index c82add430..158dddb5a 100644 --- a/src/spicelib/devices/mos2/mos2ask.c +++ b/src/spicelib/devices/mos2/mos2ask.c @@ -353,7 +353,7 @@ MOS2ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS2_CB : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS2ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -364,7 +364,7 @@ MOS2ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS2_CG : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS2ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -381,7 +381,7 @@ MOS2ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS2_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS2ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -399,7 +399,7 @@ MOS2ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS2_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS2ask.c"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/mos2/mos2noi.c b/src/spicelib/devices/mos2/mos2noi.c index 9144e57d7..b130217de 100644 --- a/src/spicelib/devices/mos2/mos2noi.c +++ b/src/spicelib/devices/mos2/mos2noi.c @@ -64,7 +64,7 @@ MOS2noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"onoise_%s%s",inst->MOS2name,MOS2nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -80,7 +80,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s%s",inst->MOS2name,MOS2nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -91,7 +91,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s%s",inst->MOS2name,MOS2nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/mos2/mos2sset.c b/src/spicelib/devices/mos2/mos2sset.c index 79e8442bb..6c486ab4b 100644 --- a/src/spicelib/devices/mos2/mos2sset.c +++ b/src/spicelib/devices/mos2/mos2sset.c @@ -39,7 +39,7 @@ MOS2sSetup(SENstruct *info, GENmodel *inModel) } } here->MOS2senPertFlag = OFF; - if((here->MOS2sens = (double *)MALLOC(70*sizeof(double))) == NULL) { + if((here->MOS2sens = TMALLOC(double, 70)) == NULL) { return(E_NOMEM); } diff --git a/src/spicelib/devices/mos3/mos3ask.c b/src/spicelib/devices/mos3/mos3ask.c index 636fbb9cb..e559b5d85 100644 --- a/src/spicelib/devices/mos3/mos3ask.c +++ b/src/spicelib/devices/mos3/mos3ask.c @@ -358,7 +358,7 @@ MOS3ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS3_CB : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS3ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -369,7 +369,7 @@ MOS3ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS3_CG : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS3ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -386,7 +386,7 @@ MOS3ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS3_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS3ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -404,7 +404,7 @@ MOS3ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case MOS3_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS3ask.c"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/mos3/mos3noi.c b/src/spicelib/devices/mos3/mos3noi.c index 41d2271b1..a68898bb3 100644 --- a/src/spicelib/devices/mos3/mos3noi.c +++ b/src/spicelib/devices/mos3/mos3noi.c @@ -64,7 +64,7 @@ MOS3noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"onoise_%s%s",inst->MOS3name,MOS3nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -80,7 +80,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s%s",inst->MOS3name,MOS3nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -91,7 +91,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s%s",inst->MOS3name,MOS3nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/mos3/mos3sset.c b/src/spicelib/devices/mos3/mos3sset.c index 4d10762d0..7bcf3f531 100644 --- a/src/spicelib/devices/mos3/mos3sset.c +++ b/src/spicelib/devices/mos3/mos3sset.c @@ -40,7 +40,7 @@ MOS3sSetup(SENstruct *info, GENmodel *inModel) } } here->MOS3senPertFlag = OFF; - if((here->MOS3sens = (double *)MALLOC(72*sizeof(double))) == NULL) { + if((here->MOS3sens = TMALLOC(double, 72)) == NULL) { return(E_NOMEM); } diff --git a/src/spicelib/devices/mos6/mos6ask.c b/src/spicelib/devices/mos6/mos6ask.c index 4d6fb5141..53869ece5 100644 --- a/src/spicelib/devices/mos6/mos6ask.c +++ b/src/spicelib/devices/mos6/mos6ask.c @@ -386,7 +386,7 @@ MOS6ask(CKTcircuit *ckt, GENinstance *inst, int which, return(OK); case MOS6_CB : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS6ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -398,7 +398,7 @@ MOS6ask(CKTcircuit *ckt, GENinstance *inst, int which, return(OK); case MOS6_CG : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS6ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -416,7 +416,7 @@ MOS6ask(CKTcircuit *ckt, GENinstance *inst, int which, return(OK); case MOS6_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS6ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -435,7 +435,7 @@ MOS6ask(CKTcircuit *ckt, GENinstance *inst, int which, return(OK); case MOS6_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS6ask.c"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/mos9/mos9ask.c b/src/spicelib/devices/mos9/mos9ask.c index 834468ffa..0d33bb642 100644 --- a/src/spicelib/devices/mos9/mos9ask.c +++ b/src/spicelib/devices/mos9/mos9ask.c @@ -355,7 +355,7 @@ MOS9ask(CKTcircuit *ckt, GENinstance *inst, int which, return(OK); case MOS9_CB : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS9ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -366,7 +366,7 @@ MOS9ask(CKTcircuit *ckt, GENinstance *inst, int which, return(OK); case MOS9_CG : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS9ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -383,7 +383,7 @@ MOS9ask(CKTcircuit *ckt, GENinstance *inst, int which, return(OK); case MOS9_CS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS9ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -401,7 +401,7 @@ MOS9ask(CKTcircuit *ckt, GENinstance *inst, int which, return(OK); case MOS9_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "MOS9ask.c"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/mos9/mos9noi.c b/src/spicelib/devices/mos9/mos9noi.c index 7ae66196b..a49d99f06 100644 --- a/src/spicelib/devices/mos9/mos9noi.c +++ b/src/spicelib/devices/mos9/mos9noi.c @@ -64,7 +64,7 @@ MOS9noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"onoise_%s%s",inst->MOS9name,MOS9nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -80,7 +80,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s%s",inst->MOS9name,MOS9nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -91,7 +91,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s%s",inst->MOS9name,MOS9nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/mos9/mos9sset.c b/src/spicelib/devices/mos9/mos9sset.c index 85ee3d403..b92cafdeb 100644 --- a/src/spicelib/devices/mos9/mos9sset.c +++ b/src/spicelib/devices/mos9/mos9sset.c @@ -42,7 +42,7 @@ MOS9sSetup(SENstruct *info, GENmodel *inModel) } } here->MOS9senPertFlag = OFF; - if((here->MOS9sens = (double *)MALLOC(72*sizeof(double))) == NULL) { + if((here->MOS9sens = TMALLOC(double, 72)) == NULL) { return(E_NOMEM); } diff --git a/src/spicelib/devices/ndev/ndevset.c b/src/spicelib/devices/ndev/ndevset.c index a60f390cb..9f46ec793 100644 --- a/src/spicelib/devices/ndev/ndevset.c +++ b/src/spicelib/devices/ndev/ndevset.c @@ -81,7 +81,7 @@ int NDEVmodelConnect(NDEVmodel *inModel) the resolved address to a readable format. */ struct sockaddr_in sa; /* Connection address. */ - char *buf = (char*) tmalloc(128); + char *buf = TMALLOC(char, 128); /* Look up the hostname with DNS. gethostbyname (at least most UNIX versions of it) properly diff --git a/src/spicelib/devices/res/resask.c b/src/spicelib/devices/res/resask.c index 8774bd53d..890c38287 100644 --- a/src/spicelib/devices/res/resask.c +++ b/src/spicelib/devices/res/resask.c @@ -135,7 +135,7 @@ RESask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case RES_CURRENT: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "RESask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -148,7 +148,7 @@ RESask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case RES_POWER: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "RESask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/res/resnoise.c b/src/spicelib/devices/res/resnoise.c index ac4ded178..50a6a4a99 100644 --- a/src/spicelib/devices/res/resnoise.c +++ b/src/spicelib/devices/res/resnoise.c @@ -76,9 +76,7 @@ RESnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"onoise_%s%s", inst->RESname, RESnNames[i]); - data->namelist = (IFuid *) - trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -93,9 +91,7 @@ RESnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, inst->RESname, RESnNames[i]); - data->namelist = (IFuid *) - trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -107,9 +103,7 @@ RESnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, inst->RESname,RESnNames[i]); - data->namelist = (IFuid *) - trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/soi3/soi3ask.c b/src/spicelib/devices/soi3/soi3ask.c index fad4a6f96..807814460 100644 --- a/src/spicelib/devices/soi3/soi3ask.c +++ b/src/spicelib/devices/soi3/soi3ask.c @@ -496,7 +496,7 @@ SOI3ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, /* case SOI3_IS : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "SOI3ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -514,7 +514,7 @@ SOI3ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case SOI3_IB : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "SOI3ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -525,7 +525,7 @@ SOI3ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case SOI3_IGF : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "SOI3ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -542,7 +542,7 @@ SOI3ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case SOI3_IGB : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "SOI3ask.c"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -559,7 +559,7 @@ SOI3ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, return(OK); case SOI3_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "SOI3ask.c"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/soi3/soi3nois.c b/src/spicelib/devices/soi3/soi3nois.c index 61045cde6..2c2c71ff5 100644 --- a/src/spicelib/devices/soi3/soi3nois.c +++ b/src/spicelib/devices/soi3/soi3nois.c @@ -89,7 +89,7 @@ SOI3noise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, (void)sprintf(name,"onoise_%s%s",inst->SOI3name,SOI3nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -105,7 +105,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s%s",inst->SOI3name,SOI3nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -115,7 +115,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s%s",inst->SOI3name,SOI3nNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/sw/swask.c b/src/spicelib/devices/sw/swask.c index dc43bebe9..1a836abec 100644 --- a/src/spicelib/devices/sw/swask.c +++ b/src/spicelib/devices/sw/swask.c @@ -41,7 +41,7 @@ SWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *se return (OK); case SW_CURRENT: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "SWask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -53,7 +53,7 @@ SWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *se return(OK); case SW_POWER: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "SWask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/sw/swnoise.c b/src/spicelib/devices/sw/swnoise.c index df0ef32f3..f54f47aa1 100644 --- a/src/spicelib/devices/sw/swnoise.c +++ b/src/spicelib/devices/sw/swnoise.c @@ -53,7 +53,7 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da (void)sprintf(name,"onoise_%s",inst->SWname); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -67,7 +67,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"onoise_total_%s",inst->SWname); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -78,7 +78,7 @@ if (!data->namelist) return(E_NOMEM); (void)sprintf(name,"inoise_total_%s",inst->SWname); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/tra/traacct.c b/src/spicelib/devices/tra/traacct.c index f41ad5318..202d71713 100644 --- a/src/spicelib/devices/tra/traacct.c +++ b/src/spicelib/devices/tra/traacct.c @@ -52,8 +52,7 @@ TRAaccept(CKTcircuit *ckt, GENmodel *inModel) if(here->TRAallocDelay <= here->TRAsizeDelay) { /* need to grab some more space */ here->TRAallocDelay += 5; - here->TRAdelays = (double *)REALLOC((char *)here->TRAdelays, - (here->TRAallocDelay+1)*3*sizeof(double)); + here->TRAdelays = TREALLOC(double, here->TRAdelays, (here->TRAallocDelay + 1) * 3); } here->TRAsizeDelay ++; to = (here->TRAdelays +3*here->TRAsizeDelay); diff --git a/src/spicelib/devices/tra/traask.c b/src/spicelib/devices/tra/traask.c index 1cdf5f548..84fa89a32 100644 --- a/src/spicelib/devices/tra/traask.c +++ b/src/spicelib/devices/tra/traask.c @@ -83,7 +83,7 @@ TRAask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *s value->rValue = here->TRAbrEq2; return (OK); case TRA_DELAY: - value->v.vec.rVec = (double *) MALLOC(here->TRAsizeDelay * sizeof(double)); + value->v.vec.rVec = TMALLOC(double, here->TRAsizeDelay); value->v.numValue = temp = here->TRAsizeDelay; v = value->v.vec.rVec; w = here->TRAdelays; diff --git a/src/spicelib/devices/tra/trasetup.c b/src/spicelib/devices/tra/trasetup.c index 4330d7c01..a4384354d 100644 --- a/src/spicelib/devices/tra/trasetup.c +++ b/src/spicelib/devices/tra/trasetup.c @@ -57,7 +57,7 @@ TRAsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state) } /* allocate the delay table */ - here->TRAdelays = (double *)MALLOC(15*sizeof(double)); + here->TRAdelays = TMALLOC(double, 15); here->TRAallocDelay = 4; /* macro to make elements with built in test for out of memory */ diff --git a/src/spicelib/devices/txl/txlload.c b/src/spicelib/devices/txl/txlload.c index 48843dbff..f9f47b6eb 100644 --- a/src/spicelib/devices/txl/txlload.c +++ b/src/spicelib/devices/txl/txlload.c @@ -349,7 +349,7 @@ static VI_list_txl pool_vi_txl = pool_vi_txl->pool; return(q); } else - return((VI_list_txl *) tmalloc (sizeof (VI_list_txl))); + return(TMALLOC(VI_list_txl, 1)); } static void diff --git a/src/spicelib/devices/txl/txlsetup.c b/src/spicelib/devices/txl/txlsetup.c index 9b427cb19..ec5bac4a2 100644 --- a/src/spicelib/devices/txl/txlsetup.c +++ b/src/spicelib/devices/txl/txlsetup.c @@ -196,7 +196,7 @@ static VI_list_txl pool_vi_txl = pool_vi_txl->pool; return(q); } else - return((VI_list_txl *) tmalloc (sizeof (VI_list_txl))); + return(TMALLOC(VI_list_txl, 1)); } ***/ @@ -215,11 +215,11 @@ ReadTxL(TXLinstance *tx, CKTcircuit *ckt) p = tx->in_node_name; n = tx->out_node_name; - line = (RLINE *) tmalloc(sizeof (RLINE)); - er = (ERLINE *) tmalloc(sizeof (ERLINE)); - et = (ETXLine *) tmalloc(sizeof (ETXLine)); - t = (TXLine *) tmalloc(sizeof (TXLine)); - t2 = (TXLine *) tmalloc(sizeof (TXLine)); + line = TMALLOC(RLINE, 1); + er = TMALLOC(ERLINE, 1); + et = TMALLOC(ETXLine, 1); + t = TMALLOC(TXLine, 1); + t2 = TMALLOC(TXLine, 1); tx->txline = t; tx->txline2 = t2; t->newtp = 0; @@ -235,14 +235,14 @@ ReadTxL(TXLinstance *tx, CKTcircuit *ckt) nd->rlptr = er; er->rl = line; line->in_node = nd; - et = (ETXLine *) tmalloc(sizeof (ETXLine)); + et = TMALLOC(ETXLine, 1); nd = insert_node(n); et->link = nd->tptr; nd->tptr = et; et->line = t; t->out_node = nd; t2->out_node = nd; - er = (ERLINE *) tmalloc(sizeof (ERLINE)); + er = TMALLOC(ERLINE, 1); er->link = nd->rlptr; nd->rlptr = er; er->rl = line; @@ -1027,7 +1027,7 @@ insert_ND(char *name, NDnamePt *ndn) NDnamePt p; if (*ndn == NULL) { - p = *ndn = (NDname*) tmalloc(sizeof (NDname)); + p = *ndn = TMALLOC(NDname, 1); p->nd = NULL; p->right = p->left = NULL; strcpy(p->id, name); @@ -1068,7 +1068,7 @@ static NODE { NODE *n; - n = (NODE *) tmalloc (sizeof (NODE)); + n = TMALLOC(NODE, 1); n->mptr = NULL; n->gptr = NULL; n->cptr = NULL; diff --git a/src/spicelib/devices/urc/urcsetup.c b/src/spicelib/devices/urc/urcsetup.c index 74611f790..ae49c0242 100644 --- a/src/spicelib/devices/urc/urcsetup.c +++ b/src/spicelib/devices/urc/urcsetup.c @@ -127,7 +127,7 @@ URCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state) lowl = CKTnum2nod(ckt,here->URCposNode); hir = CKTnum2nod(ckt,here->URCnegNode); for(i=1;i<=here->URClumps;i++) { - namehi = (char *)MALLOC(10*sizeof(char)); + namehi = TMALLOC(char, 10); (void)sprintf(namehi,"hi%d",i); error = CKTmkVolt(ckt,(CKTnode**)&nodehi,here->URCname,namehi); if(error) return(error); @@ -135,7 +135,7 @@ URCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state) if(i==here->URClumps) { lowr = hil; } else { - namelo = (char *)MALLOC(10*sizeof(char)); + namelo = TMALLOC(char, 10); (void)sprintf(namelo,"lo%d",i); error = CKTmkVolt(ckt,(CKTnode**)&nodelo,here->URCname, namelo); @@ -145,7 +145,7 @@ URCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state) r = prop*r1; c = prop*c1; - nameelt = (char *)MALLOC(10*sizeof(char)); + nameelt = TMALLOC(char, 10); (void)sprintf(nameelt,"rlo%d",i); error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,here->URCname, nameelt, UID_INSTANCE, NULL); @@ -162,7 +162,7 @@ URCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state) if(error) return(error); fast->GENowner = here->URCowner; - nameelt = (char *)MALLOC(10*sizeof(char)); + nameelt = TMALLOC(char, 10); (void)sprintf(nameelt,"rhi%d",i); error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,here->URCname, nameelt, UID_INSTANCE, NULL); @@ -181,7 +181,7 @@ URCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state) if(model->URCisPerLGiven) { /* use diode */ - nameelt = (char *)MALLOC(10*sizeof(char)); + nameelt = TMALLOC(char, 10); (void)sprintf(nameelt,"dlo%d",i); error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid, here->URCname,nameelt,UID_INSTANCE, @@ -201,7 +201,7 @@ URCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state) fast->GENowner = here->URCowner; } else { /* use simple capacitor */ - nameelt = (char *)MALLOC(10*sizeof(char)); + nameelt = TMALLOC(char, 10); (void)sprintf(nameelt,"clo%d",i); error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,here->URCname ,nameelt, UID_INSTANCE, NULL); @@ -224,7 +224,7 @@ URCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state) if(i!=here->URClumps){ if(model->URCisPerLGiven) { /* use diode */ - nameelt = (char *)MALLOC(10*sizeof(char)); + nameelt = TMALLOC(char, 10); (void)sprintf(nameelt,"dhi%d",i); error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid, here->URCname,nameelt,UID_INSTANCE, @@ -244,7 +244,7 @@ URCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state) fast->GENowner = here->URCowner; } else { /* use simple capacitor */ - nameelt = (char *)MALLOC(10*sizeof(char)); + nameelt = TMALLOC(char, 10); (void)sprintf(nameelt,"chi%d",i); error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid, here->URCname,nameelt,UID_INSTANCE, diff --git a/src/spicelib/devices/vbic/vbicnoise.c b/src/spicelib/devices/vbic/vbicnoise.c index 549d04c05..66ff7ffe8 100644 --- a/src/spicelib/devices/vbic/vbicnoise.c +++ b/src/spicelib/devices/vbic/vbicnoise.c @@ -79,9 +79,7 @@ VBICnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata * inst->VBICname,VBICnNames[i]); - data->namelist = (IFuid *) - trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -95,9 +93,7 @@ VBICnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata * (void)sprintf(name,"onoise_total_%s%s", inst->VBICname,VBICnNames[i]); - data->namelist = (IFuid *) - trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); + data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), @@ -107,7 +103,7 @@ VBICnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata * (void)sprintf(name,"inoise_total_%s%s", inst->VBICname,VBICnNames[i]); -data->namelist = (IFuid *)trealloc((char *)data->namelist,(data->numPlots + 1)*sizeof(IFuid)); +data->namelist = TREALLOC(IFuid, data->namelist, data->numPlots + 1); if (!data->namelist) return(E_NOMEM); (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), diff --git a/src/spicelib/devices/vccs/vccsask.c b/src/spicelib/devices/vccs/vccsask.c index 19e1a260b..0cc87ed29 100644 --- a/src/spicelib/devices/vccs/vccsask.c +++ b/src/spicelib/devices/vccs/vccsask.c @@ -109,7 +109,7 @@ VCCSask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return(OK); case VCCS_CURRENT: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "VCCSask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -125,7 +125,7 @@ VCCSask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return (OK); case VCCS_POWER: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "VCCSask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/vcvs/vcvsask.c b/src/spicelib/devices/vcvs/vcvsask.c index 0228360df..a34fd8c41 100644 --- a/src/spicelib/devices/vcvs/vcvsask.c +++ b/src/spicelib/devices/vcvs/vcvsask.c @@ -116,7 +116,7 @@ VCVSask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return(OK); case VCVS_CURRENT : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "VCVSask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -130,7 +130,7 @@ VCVSask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return(OK); case VCVS_POWER : if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "VCVSask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/devices/vsrc/vsrcask.c b/src/spicelib/devices/vsrc/vsrcask.c index 799be48a4..ce51950c7 100644 --- a/src/spicelib/devices/vsrc/vsrcask.c +++ b/src/spicelib/devices/vsrc/vsrcask.c @@ -46,8 +46,7 @@ VSRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * case VSRC_AM: case VSRC_FCN_COEFFS: temp = value->v.numValue = here->VSRCfunctionOrder; - v = value->v.vec.rVec = (double *) - MALLOC (here->VSRCfunctionOrder * sizeof(double)); + v = value->v.vec.rVec = TMALLOC(double, here->VSRCfunctionOrder); w = here->VSRCcoeffs; while (temp--) { *v++ = *w++; @@ -55,8 +54,7 @@ VSRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return (OK); case VSRC_AC: value->v.numValue = 2; - value->v.vec.rVec = (double *) - MALLOC (value->v.numValue * sizeof (double)); + value->v.vec.rVec = TMALLOC(double, value->v.numValue); value->v.vec.rVec[0] = here->VSRCacMag; value->v.vec.rVec[1] = here->VSRCacPhase; return (OK); @@ -86,7 +84,7 @@ VSRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return (OK); case VSRC_CURRENT: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "VSRCask"; strcpy(errMsg,msg); return(E_ASKCURRENT); @@ -96,7 +94,7 @@ VSRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * return(OK); case VSRC_POWER: if (ckt->CKTcurrentAnalysis & DOING_AC) { - errMsg = (char*) MALLOC(strlen(msg)+1); + errMsg = TMALLOC(char, strlen(msg) + 1); errRtn = "VSRCask"; strcpy(errMsg,msg); return(E_ASKPOWER); diff --git a/src/spicelib/parser/ifnewuid.c b/src/spicelib/parser/ifnewuid.c index bb3374d9a..b74135ca6 100644 --- a/src/spicelib/parser/ifnewuid.c +++ b/src/spicelib/parser/ifnewuid.c @@ -39,8 +39,7 @@ IFnewUid(CKTcircuit *ckt, IFuid * newuid, IFuid olduid, char *suffix, int type, #ifdef HAVE_ASPRINTF asprintf(&newname, "%s#%s", (char *) olduid, suffix); #else /* ~ HAVE_ASPRINTF */ - newname = (char *) tmalloc(strlen((char *) olduid) + - strlen(suffix) + 2); /* 2 = strlen("#\0") */ + newname = TMALLOC(char, strlen((char *) olduid) + strlen(suffix) + 2); /* 2 = strlen("#\0") */ sprintf(newname, "%s#%s", (char *) olduid, suffix); #endif /* HAVE_ASPRINTF */ @@ -49,7 +48,7 @@ IFnewUid(CKTcircuit *ckt, IFuid * newuid, IFuid olduid, char *suffix, int type, #ifdef HAVE_ASPRINTF asprintf(&newname, "%s", suffix); #else /* ~ HAVE_ASPRINTF */ - newname = (char *) tmalloc(strlen(suffix) + 1 ); + newname = TMALLOC(char, strlen(suffix) + 1); sprintf(newname, "%s", suffix); #endif /* HAVE_ASPRINTF */ } diff --git a/src/spicelib/parser/inp2dot.c b/src/spicelib/parser/inp2dot.c index a43ea4e6e..964829f71 100644 --- a/src/spicelib/parser/inp2dot.c +++ b/src/spicelib/parser/inp2dot.c @@ -362,15 +362,14 @@ dot_tf(char *line, CKTcircuit *ckt, INPtables *tab, card *current, ptemp.nValue = node2; GCA(INPapName, (ckt, which, foo, "outneg", &ptemp)); ptemp.sValue = - (char *) MALLOC(sizeof(char) * - (5 + strlen(nname1) + strlen(nname2))); + TMALLOC(char, 5 + strlen(nname1) + strlen(nname2)); (void) sprintf(ptemp.sValue, "V(%s,%s)", nname1, nname2); GCA(INPapName, (ckt, which, foo, "outname", &ptemp)); } else { ptemp.nValue = gnode; GCA(INPapName, (ckt, which, foo, "outneg", &ptemp)); ptemp.sValue = - (char *) MALLOC(sizeof(char) * (4 + strlen(nname1))); + TMALLOC(char, 4 + strlen(nname1)); (void) sprintf(ptemp.sValue, "V(%s)", nname1); GCA(INPapName, (ckt, which, foo, "outname", &ptemp)); } @@ -497,16 +496,14 @@ dot_sens(char *line, CKTcircuit *ckt, INPtables *tab, card *current, INPtermInsert(ckt, &nname2, tab, &node2); ptemp.nValue = node2; GCA(INPapName, (ckt, which, foo, "outneg", &ptemp)); - ptemp.sValue = (char *) - MALLOC(sizeof(char) * - (5 + strlen(nname1) + strlen(nname2))); + ptemp.sValue = TMALLOC(char, 5 + strlen(nname1) + strlen(nname2)); (void) sprintf(ptemp.sValue, "V(%s,%s)", nname1, nname2); GCA(INPapName, (ckt, which, foo, "outname", &ptemp)); } else { ptemp.nValue = gnode; GCA(INPapName, (ckt, which, foo, "outneg", &ptemp)); ptemp.sValue = - (char *) MALLOC(sizeof(char) * (4 + strlen(nname1))); + TMALLOC(char, 4 + strlen(nname1)); (void) sprintf(ptemp.sValue, "V(%s)", nname1); GCA(INPapName, (ckt, which, foo, "outname", &ptemp)); } diff --git a/src/spicelib/parser/inp2p.c b/src/spicelib/parser/inp2p.c index 088fcf43c..e0a34e1bf 100644 --- a/src/spicelib/parser/inp2p.c +++ b/src/spicelib/parser/inp2p.c @@ -62,10 +62,10 @@ int num, i; line = current->line; INPgetTok(&line,&name,1); - nname1 = (char **) tmalloc(num * sizeof(char *)); - nname2 = (char **) tmalloc(num * sizeof(char *)); - node1 = (CKTnode **) tmalloc(num * sizeof(CKTnode *)); - node2 = (CKTnode **) tmalloc(num * sizeof(CKTnode *)); + nname1 = TMALLOC(char *, num); + nname2 = TMALLOC(char *, num); + node1 = TMALLOC(CKTnode *, num); + node2 = TMALLOC(CKTnode *, num); for (i = 0; i < num; i++) { INPgetNetTok(&line,&(nname1[i]),1); diff --git a/src/spicelib/parser/inp2q.c b/src/spicelib/parser/inp2q.c index b74bd17e3..fe8cd49ba 100644 --- a/src/spicelib/parser/inp2q.c +++ b/src/spicelib/parser/inp2q.c @@ -160,7 +160,7 @@ void INP2Q(CKTcircuit *ckt, INPtables * tab, card * current, CKTnode *gnode) char *err; IFnewUid(ckt, &uid, (IFuid) NULL, "Q", UID_MODEL, NULL); IFC(newModel, (ckt, type, &(tab->defQmod), uid)); - err = (char *) MALLOC((70 + strlen(model)) * sizeof(char)); + err = TMALLOC(char, 70 + strlen(model)); (void) sprintf(err, "Unable to find definition of model %s - default BJT assumed \n", model); LITERR(err); tfree(err); diff --git a/src/spicelib/parser/inp2r.c b/src/spicelib/parser/inp2r.c index 19814de84..7a40bef45 100644 --- a/src/spicelib/parser/inp2r.c +++ b/src/spicelib/parser/inp2r.c @@ -125,7 +125,7 @@ void INP2R(CKTcircuit *ckt, INPtables * tab, card * current) /* first alocate memory for the new longer line */ i = strlen(current->line); /* length of existing line */ - line = (char*) tmalloc(i + 4 + 1); /* alocate enough for "tc2=" & terminating NULL */ + line = TMALLOC(char, i + 4 + 1); /* alocate enough for "tc2=" & terminating NULL */ if(line == NULL) { /* failed to allocate memory so we recover rather crudely by rejecting the translation */ diff --git a/src/spicelib/parser/inp2y.c b/src/spicelib/parser/inp2y.c index c970cea87..6487244b9 100644 --- a/src/spicelib/parser/inp2y.c +++ b/src/spicelib/parser/inp2y.c @@ -122,7 +122,7 @@ int lenvalgiven = 0; type = INPtypelook("Resistor"); /* resistor between node1 and internal1 */ - internal1 = (char *) tmalloc (10); + internal1 = TMALLOC(char, 10); strcpy(internal1, "txlnd1"); INPtermInsert(ckt, &internal1, tab, &inode1); if(!tab->defRmod) { @@ -139,7 +139,7 @@ int lenvalgiven = 0; GCA(INPpName,("resistance",&ptemp,ckt,type,fast)) /* resistor between internal1 and internal2 */ - internal2 = (char *) tmalloc (10); + internal2 = TMALLOC(char, 10); strcpy(internal2, "txlnd2"); INPtermInsert(ckt, &internal2, tab, &inode2); strcpy(rname2, "txlres2"); diff --git a/src/spicelib/parser/inpdomod.c b/src/spicelib/parser/inpdomod.c index 0d9a32292..8850806fd 100644 --- a/src/spicelib/parser/inpdomod.c +++ b/src/spicelib/parser/inpdomod.c @@ -297,7 +297,7 @@ char *INPdomodel(CKTcircuit *ckt, card * image, INPtables * tab) type = INPtypelook("BSIM3"); } if (type < 0) { - err = (char *) tmalloc(sizeof(char) * (60 + strlen(ver))); + err = TMALLOC(char, 60 + strlen(ver)); sprintf(err,"Device type BSIM3 version %s not available in this binary\n",ver); } break; @@ -327,7 +327,7 @@ char *INPdomodel(CKTcircuit *ckt, card * image, INPtables * tab) type = INPtypelook("BSIM4"); } if (type < 0) { - err = (char *) tmalloc(sizeof(char) * (60 + strlen(ver))); + err = TMALLOC(char, 60 + strlen(ver)); sprintf(err,"Device type BSIM4 version %s not available in this binary\n",ver); } break; @@ -626,7 +626,7 @@ char *INPdomodel(CKTcircuit *ckt, card * image, INPtables * tab) else { #ifndef XSPICE type = -1; - err = (char *) MALLOC(35 + strlen(typename)); + err = TMALLOC(char, 35 + strlen(typename)); (void) sprintf(err, "unknown model type %s - ignored\n", typename); #else /* gtri - modify - wbk - 10/23/90 - modify to look for code models */ @@ -638,7 +638,7 @@ char *INPdomodel(CKTcircuit *ckt, card * image, INPtables * tab) /* look for this model type and put it in the table of models */ type = INPtypelook(typename); if(type < 0) { - err = (char *) MALLOC(35 + strlen(typename)); + err = TMALLOC(char, 35 + strlen(typename)); sprintf(err,"Unknown model type %s - ignored\n",typename); #ifdef TRACE diff --git a/src/spicelib/parser/inpdoopt.c b/src/spicelib/parser/inpdoopt.c index 7e7632751..8355f35b8 100644 --- a/src/spicelib/parser/inpdoopt.c +++ b/src/spicelib/parser/inpdoopt.c @@ -55,7 +55,7 @@ INPdoOpts( for(i=0;inumParms;i++) { if(strcmp(token,prm->analysisParms[i].keyword) == 0) { if(!(prm->analysisParms[i].dataType & IF_UNIMP_MASK)) { - errmsg = (char *)MALLOC((45+strlen(token)) * sizeof(char)); + errmsg = TMALLOC(char, 45 + strlen(token)); (void) sprintf(errmsg, " Warning: %s not yet implemented - ignored \n",token); optCard->error = INPerrCat(optCard->error,errmsg); @@ -69,7 +69,7 @@ INPdoOpts( error = (*(ft_sim->setAnalysisParm))(ckt,anal, prm->analysisParms[i].id,val,(IFvalue*)NULL); if(error) { - errmsg =(char *)MALLOC((35+strlen(token))*sizeof(char)); + errmsg = TMALLOC(char, 35 + strlen(token)); (void) sprintf(errmsg, "Warning: can't set option %s\n", token); optCard->error = INPerrCat(optCard->error, errmsg); @@ -79,7 +79,7 @@ INPdoOpts( } } if(i == prm->numParms) { - errmsg = (char *)MALLOC(100 * sizeof(char)); + errmsg = TMALLOC(char, 100); (void) strcpy(errmsg," Error: unknown option - ignored\n"); optCard->error = INPerrCat(optCard->error,errmsg); fprintf(stderr, "%s\n", optCard->error); diff --git a/src/spicelib/parser/inpdpar.c b/src/spicelib/parser/inpdpar.c index d07cd0846..ae807bd97 100644 --- a/src/spicelib/parser/inpdpar.c +++ b/src/spicelib/parser/inpdpar.c @@ -79,7 +79,7 @@ char *INPdevParse(char **line, CKTcircuit *ckt, int dev, GENinstance *fast, } } if (i == (*(*(ft_sim->devices)[dev]).numInstanceParms)) { - errbuf = (char*) MALLOC(strlen(parm) + 25); + errbuf = TMALLOC(char, strlen(parm) + 25); (void) sprintf(errbuf, " unknown parameter (%s) \n", parm); rtn = (errbuf); goto quit; diff --git a/src/spicelib/parser/inperrc.c b/src/spicelib/parser/inperrc.c index e2459d45a..c235c4547 100644 --- a/src/spicelib/parser/inperrc.c +++ b/src/spicelib/parser/inperrc.c @@ -20,8 +20,7 @@ char *INPerrCat(char *a, char *b) } else { /* both valid - hard work... */ register char *errtmp; errtmp = - (char *) MALLOC((strlen(a) + strlen(b) + 2) * - sizeof(char)); + TMALLOC(char, strlen(a) + strlen(b) + 2); (void) strcpy(errtmp, a); (void) strcat(errtmp, "\n"); (void) strcat(errtmp, b); diff --git a/src/spicelib/parser/inperror.c b/src/spicelib/parser/inperror.c index 347bdf882..e8f3917fa 100644 --- a/src/spicelib/parser/inperror.c +++ b/src/spicelib/parser/inperror.c @@ -47,11 +47,11 @@ char *INPerror(int type) asprintf(&ebuf, "%s\n", val); #else /* ~ HAVE_ASPRINTF */ if (errRtn){ - ebuf = (char *) tmalloc(strlen(val) + strlen(errRtn) + 25); + ebuf = TMALLOC(char, strlen(val) + strlen(errRtn) + 25); sprintf(ebuf, "%s detected in routine \"%s\"\n", val, errRtn); } else{ - ebuf = (char *) tmalloc(strlen(val) + 2); + ebuf = TMALLOC(char, strlen(val) + 2); sprintf(ebuf, "%s\n", val); } #endif /* HAVE_ASPRINTF */ diff --git a/src/spicelib/parser/inpgmod.c b/src/spicelib/parser/inpgmod.c index b3a01e33f..8f41f3f02 100644 --- a/src/spicelib/parser/inpgmod.c +++ b/src/spicelib/parser/inpgmod.c @@ -125,7 +125,7 @@ create_model( CKTcircuit* ckt, INPmodel* modtmp, INPtables* tab ) exit(EXIT_FAILURE); } if (endptr == parm) { /* it was no number - it is really a string */ - temp = (char *) MALLOC((40 + strlen(parm)) * sizeof(char)); + temp = TMALLOC(char, 40 + strlen(parm)); (void) sprintf(temp, "unrecognized parameter (%s) - ignored", parm); err = INPerrCat(err, temp); @@ -265,7 +265,7 @@ char *INPgetMod(CKTcircuit *ckt, char *name, INPmodel ** model, INPtables * tab) if (modtmp->INPmodType < 0) { /* First check for illegal model type */ /* illegal device type, so can't handle */ *model = (INPmodel *) NULL; - err = (char *) MALLOC((35 + strlen(name)) * sizeof(char)); + err = TMALLOC(char, 35 + strlen(name)); (void) sprintf(err,"Unknown device type for model %s \n", name); #ifdef TRACE @@ -286,7 +286,7 @@ char *INPgetMod(CKTcircuit *ckt, char *name, INPmodel ** model, INPtables * tab) } /* didn't find model - ERROR - return model */ *model = (INPmodel *) NULL; - err = (char *) MALLOC((60 + strlen(name)) * sizeof(char)); + err = TMALLOC(char, 60 + strlen(name)); (void) sprintf(err, "Unable to find definition of model %s - default assumed \n", name); #ifdef TRACE @@ -358,7 +358,7 @@ INPparseNumMod( CKTcircuit* ckt, INPmodel *model, INPtables *tab, char **errMess cardType = lastType; while (*line == '+') line++; /* Skip leading '+'s */ } else { - tmp = (char *)tmalloc((55)*sizeof(char)); + tmp = TMALLOC(char, 55); (void) sprintf(tmp, "Error on card %d : illegal continuation \'+\' - ignored", cardNum); @@ -391,7 +391,7 @@ INPparseNumMod( CKTcircuit* ckt, INPmodel *model, INPtables *tab, char **errMess cardType = E_MISSING; } else { /* Error */ - tmp =(char *)tmalloc((55+strlen(cardName))*sizeof(char)); + tmp = TMALLOC(char, 55 + strlen(cardName)); (void) sprintf(tmp, "Error on card %d : unrecognized name (%s) - ignored", cardNum, cardName ); @@ -414,14 +414,14 @@ INPparseNumMod( CKTcircuit* ckt, INPmodel *model, INPtables *tab, char **errMess idx = INPfindParm(parm, info->cardParms, info->numParms); if (idx == E_MISSING) { /* parm not found */ - tmp = (char *)tmalloc((60+strlen(parm)) * sizeof(char)); + tmp = TMALLOC(char, 60 + strlen(parm)); (void)sprintf(tmp, "Error on card %d : unrecognized parameter (%s) - ignored", cardNum, parm); err = INPerrCat(err, tmp); } else if (idx == E_AMBIGUOUS) { /* parm ambiguous */ - tmp = (char *)tmalloc((58+strlen(parm)) * sizeof(char)); + tmp = TMALLOC(char, 58 + strlen(parm)); (void)sprintf(tmp, "Error on card %d : ambiguous parameter (%s) - ignored", cardNum, parm); @@ -434,7 +434,7 @@ INPparseNumMod( CKTcircuit* ckt, INPmodel *model, INPtables *tab, char **errMess == IF_FLAG) { value->iValue = 0; } else { - tmp =(char *)tmalloc((63+strlen(parm))*sizeof(char)); + tmp = TMALLOC(char, 63 + strlen(parm)); (void)sprintf(tmp, "Error on card %d : non-boolean parameter (%s) - \'^\' ignored", cardNum, parm); diff --git a/src/spicelib/parser/inpgstr.c b/src/spicelib/parser/inpgstr.c index 4081cb48b..d0270d627 100644 --- a/src/spicelib/parser/inpgstr.c +++ b/src/spicelib/parser/inpgstr.c @@ -48,7 +48,7 @@ int INPgetStr(char **line, char **token, int gobble) } /* Create token */ - *token = (char *) MALLOC(1 + point - *line); + *token = TMALLOC(char, 1 + point - *line); if (!*token) return (E_NOMEM); (void) strncpy(*token, *line, point - *line); diff --git a/src/spicelib/parser/inpgtok.c b/src/spicelib/parser/inpgtok.c index 5f6d87031..f98f80387 100644 --- a/src/spicelib/parser/inpgtok.c +++ b/src/spicelib/parser/inpgtok.c @@ -98,7 +98,7 @@ int INPgetTok(char **line, char **token, int gobble) diffpoints = point - *line; if ((diffpoints < 1) && *point) diffpoints = 1; /* Weird items, 1 char */ - *token = (char *) tmalloc((1 + diffpoints)*sizeof(char)); + *token = TMALLOC(char, 1 + diffpoints); if (!*token) return (E_NOMEM); (void) strncpy(*token, *line, diffpoints); @@ -107,7 +107,7 @@ int INPgetTok(char **line, char **token, int gobble) /* if (point == *line && *point) point++; - *token = (char *) MALLOC(1 + point - *line); + *token = TMALLOC(char, 1 + point - *line); if (!*token) return (E_NOMEM); (void) strncpy(*token, *line, point - *line); @@ -196,7 +196,7 @@ int INPgetNetTok(char **line, char **token, int gobble) diffpoints = point - *line; if ((diffpoints < 1) && *point) diffpoints = 1; /* Weird items, 1 char */ - *token = (char *) tmalloc((1 + diffpoints)*sizeof(char)); + *token = TMALLOC(char, 1 + diffpoints); if (!*token) return (E_NOMEM); (void) strncpy(*token, *line, diffpoints); @@ -206,7 +206,7 @@ int INPgetNetTok(char **line, char **token, int gobble) /* if (point == *line && *point) point++; - *token = (char *) MALLOC(1 + point - *line); + *token = TMALLOC(char, 1 + point - *line); if (!*token) return (E_NOMEM); (void) strncpy(*token, *line, point - *line); @@ -328,7 +328,7 @@ int INPgetUTok(char **line, char **token, int gobble) point--; if (point == *line && *point) /* Weird items, 1 char */ point++; - *token = (char *) MALLOC(1 + point - *line); + *token = TMALLOC(char, 1 + point - *line); if (!*token) return (E_NOMEM); (void) strncpy(*token, *line, point - *line); @@ -455,7 +455,7 @@ int INPgetU2Tok(char **line, char **token, int gobble) point--; if (point == *line && *point) /* Weird items, 1 char */ point++; - *token = (char *) MALLOC(1 + point - *line); + *token = TMALLOC(char, 1 + point - *line); if (!*token) return (E_NOMEM); (void) strncpy(*token, *line, point - *line); diff --git a/src/spicelib/parser/inpgval.c b/src/spicelib/parser/inpgval.c index c4b28953f..b5baef80a 100644 --- a/src/spicelib/parser/inpgval.c +++ b/src/spicelib/parser/inpgval.c @@ -31,28 +31,26 @@ IFvalue *INPgetValue(CKTcircuit *ckt, char **line, int type, INPtables * tab) /*printf(" returning real value %e\n",temp.rValue); */ } else if (type == IF_REALVEC) { temp.v.numValue = 0; - list = (double *) MALLOC(sizeof(double)); + list = TMALLOC(double, 1); tmp = INPevaluate(line, &error, 1); while (error == 0) { /*printf(" returning vector value %g\n",tmp); */ temp.v.numValue++; list = - (double *) REALLOC((char *) list, - temp.v.numValue * sizeof(double)); + TREALLOC(double, list, temp.v.numValue); *(list + temp.v.numValue - 1) = tmp; tmp = INPevaluate(line, &error, 1); } temp.v.vec.rVec = list; } else if (type == IF_INTVEC) { temp.v.numValue = 0; - ilist = (int *) MALLOC(sizeof(int)); + ilist = TMALLOC(int, 1); tmp = INPevaluate(line, &error, 1); while (error == 0) { /*printf(" returning vector value %g\n",tmp); */ temp.v.numValue++; ilist = - (int *) REALLOC((char *) ilist, - temp.v.numValue * sizeof(int)); + TREALLOC(int, ilist, temp.v.numValue); *(ilist + temp.v.numValue - 1) = (int) floor(0.5 + tmp); tmp = INPevaluate(line, &error, 1); } diff --git a/src/spicelib/parser/inpmkmod.c b/src/spicelib/parser/inpmkmod.c index 2cb4f3f9e..b11bdfb0e 100644 --- a/src/spicelib/parser/inpmkmod.c +++ b/src/spicelib/parser/inpmkmod.c @@ -39,7 +39,7 @@ int INPmakeMod(char *token, int type, card * line) printf("In INPmakeMod, about to insert new model name = %s . . .\n", token); #endif - *i = (INPmodel *) MALLOC(sizeof(INPmodel)); + *i = TMALLOC(INPmodel, 1); if (*i == NULL) return (E_NOMEM); diff --git a/src/spicelib/parser/inpmktmp.c b/src/spicelib/parser/inpmktmp.c index 5855cd652..e2932f06a 100644 --- a/src/spicelib/parser/inpmktmp.c +++ b/src/spicelib/parser/inpmktmp.c @@ -17,7 +17,7 @@ char *INPmkTemp(char *string) char *temp; len = strlen(string); - temp = (char*) MALLOC(len + 1); + temp = TMALLOC(char, len + 1); if (temp != (char *) NULL) (void) strcpy(temp, string); return (temp); diff --git a/src/spicelib/parser/inpptree.c b/src/spicelib/parser/inpptree.c index ad318e6b1..691f73bdb 100644 --- a/src/spicelib/parser/inpptree.c +++ b/src/spicelib/parser/inpptree.c @@ -140,7 +140,7 @@ INPgetTree(char **line, INPparseTree ** pt, CKTcircuit *ckt, INPtables * tab) return; } - (*pt) = (INPparseTree *) MALLOC(sizeof(INPparseTree)); + (*pt) = TMALLOC(INPparseTree, 1); (*pt)->p.numVars = numvalues; (*pt)->p.varTypes = types; @@ -148,8 +148,7 @@ INPgetTree(char **line, INPparseTree ** pt, CKTcircuit *ckt, INPtables * tab) (*pt)->p.IFeval = IFeval; (*pt)->tree = p; - (*pt)->derivs = (INPparseNode **) - MALLOC(numvalues * sizeof(INPparseNode *)); + (*pt)->derivs = TMALLOC(INPparseNode *, numvalues); for (i = 0; i < numvalues; i++) (*pt)->derivs[i] = PTdifferentiate(p, i); @@ -541,7 +540,7 @@ static INPparseNode *PTdifferentiate(INPparseNode * p, int varnum) static INPparseNode *mkcon(double value) { - INPparseNode *p = (INPparseNode *) MALLOC(sizeof(INPparseNode)); + INPparseNode *p = TMALLOC(INPparseNode, 1); p->type = PT_CONSTANT; p->constant = value; @@ -552,7 +551,7 @@ static INPparseNode *mkcon(double value) static INPparseNode *mkb(int type, INPparseNode * left, INPparseNode * right) { - INPparseNode *p = (INPparseNode *) MALLOC(sizeof(INPparseNode)); + INPparseNode *p = TMALLOC(INPparseNode, 1); int i; if ((right->type == PT_CONSTANT) && (left->type == PT_CONSTANT)) { @@ -652,7 +651,7 @@ static INPparseNode *mkb(int type, INPparseNode * left, static INPparseNode *mkf(int type, INPparseNode * arg) { - INPparseNode *p = (INPparseNode *) MALLOC(sizeof(INPparseNode)); + INPparseNode *p = TMALLOC(INPparseNode, 1); int i; double constval; @@ -731,7 +730,7 @@ static INPparseNode *mkbnode(const char *opstr, INPparseNode * arg1, fprintf(stderr, "Internal Error: no such op num %s\n", opstr); return (NULL); } - p = (INPparseNode *) MALLOC(sizeof(INPparseNode)); + p = TMALLOC(INPparseNode, 1); p->type = ops[i].number; p->funcname = ops[i].name; @@ -786,8 +785,8 @@ static INPparseNode *prepare_PTF_PWL(INPparseNode *p) return (NULL); } - data = (struct pwldata *) MALLOC(sizeof(struct pwldata)); - data->vals = (double*) MALLOC(i*sizeof(double)); + data = TMALLOC(struct pwldata, 1); + data->vals = TMALLOC(double, i); data->n = i; @@ -841,10 +840,10 @@ static INPparseNode *mkfnode(const char *fname, INPparseNode * arg) if (isupper(*s)) *s = tolower(*s); - p = (INPparseNode *) MALLOC(sizeof(INPparseNode)); + p = TMALLOC(INPparseNode, 1); if (!strcmp(buf, "v")) { - name = (char*) MALLOC(128); + name = TMALLOC(char, 128); if (arg->type == PT_PLACEHOLDER) { strcpy(name, arg->funcname); } else if (arg->type == PT_CONSTANT) { @@ -865,15 +864,11 @@ static INPparseNode *mkfnode(const char *fname, INPparseNode * arg) break; if (i == numvalues) { if (numvalues) { - values = (IFvalue *) - REALLOC((char *) values, - (numvalues + 1) * sizeof(IFvalue)); - types = (int *) - REALLOC((char *) types, - (numvalues + 1) * sizeof(int)); + values = TREALLOC(IFvalue, values, numvalues + 1); + types = TREALLOC(int, types, numvalues + 1); } else { - values = (IFvalue *) MALLOC(sizeof(IFvalue)); - types = (int *) MALLOC(sizeof(int)); + values = TMALLOC(IFvalue, 1); + types = TMALLOC(int, 1); } values[i].nValue = temp; types[i] = IF_NODE; @@ -883,7 +878,7 @@ static INPparseNode *mkfnode(const char *fname, INPparseNode * arg) p->type = PT_VAR; } } else if (!strcmp(buf, "i")) { - name = (char*) MALLOC(128); + name = TMALLOC(char, 128); if (arg->type == PT_PLACEHOLDER) strcpy(name, arg->funcname); else if (arg->type == PT_CONSTANT) @@ -898,14 +893,11 @@ static INPparseNode *mkfnode(const char *fname, INPparseNode * arg) break; if (i == numvalues) { if (numvalues) { - values = (IFvalue *) - REALLOC((char *) values, - (numvalues + 1) * sizeof(IFvalue)); - types = (int *) - REALLOC((char *) types, (numvalues + 1) * sizeof(int)); + values = TREALLOC(IFvalue, values, numvalues + 1); + types = TREALLOC(int, types, numvalues + 1); } else { - values = (IFvalue *) MALLOC(sizeof(IFvalue)); - types = (int *) MALLOC(sizeof(int)); + values = TMALLOC(IFvalue, 1); + types = TMALLOC(int, 1); } values[i].uValue = (IFuid) name; types[i] = IF_INSTANCE; @@ -966,7 +958,7 @@ static INPparseNode *mknnode(double number) { struct INPparseNode *p; - p = (INPparseNode *) MALLOC(sizeof(INPparseNode)); + p = TMALLOC(INPparseNode, 1); p->type = PT_CONSTANT; p->constant = number; @@ -988,7 +980,7 @@ static INPparseNode *mksnode(const char *string, void *ckt) if (isupper(*s)) *s = tolower(*s); - p = (INPparseNode *) MALLOC(sizeof(INPparseNode)); + p = TMALLOC(INPparseNode, 1); if(!strcmp("time", buf)) { p->type = PT_TIME; @@ -1018,16 +1010,13 @@ static INPparseNode *mksnode(const char *string, void *ckt) break; if (j == numvalues) { if (numvalues) { - values = (IFvalue *) - REALLOC((char *) values, - (numvalues + 1) * sizeof(IFvalue)); - types = (int *) - REALLOC((char *) types, (numvalues + 1) * sizeof(int)); + values = TREALLOC(IFvalue, values, numvalues + 1); + types = TREALLOC(int, types, numvalues + 1); } else { - values = (IFvalue *) MALLOC(sizeof(IFvalue)); - types = (int *) MALLOC(sizeof(int)); + values = TMALLOC(IFvalue, 1); + types = TMALLOC(int, 1); } - values[i].sValue = (char*) MALLOC(strlen(buf) + 1); + values[i].sValue = TMALLOC(char, strlen(buf) + 1); strcpy(values[i].sValue, buf); types[i] = IF_STRING; numvalues++; @@ -1176,7 +1165,7 @@ int PTlex (YYSTYPE *lvalp, char **line) for (s = sbuf; *s; s++) if (index(specials, *s)) break; - tmp = (char*) MALLOC(s - sbuf + 1); + tmp = TMALLOC(char, s - sbuf + 1); strncpy(tmp, sbuf, s - sbuf); tmp[s - sbuf] = '\0'; lvalp->str = tmp; diff --git a/src/spicelib/parser/inpsymt.c b/src/spicelib/parser/inpsymt.c index cfd03a830..6bb0261fc 100644 --- a/src/spicelib/parser/inpsymt.c +++ b/src/spicelib/parser/inpsymt.c @@ -27,13 +27,10 @@ INPtables *INPtabInit(int numlines) { INPtables *tab; - tab = (INPtables *) tmalloc(sizeof(INPtables)); - tab->INPsymtab = (struct INPtab **) tmalloc((numlines / 4 + 1) * - sizeof(struct INPtab *)); + tab = TMALLOC(INPtables, 1); + tab->INPsymtab = TMALLOC(struct INPtab *, numlines / 4 + 1); ZERO(tab->INPsymtab, (numlines / 4 + 1) * sizeof(struct INPtab *)); - tab->INPtermsymtab = (struct INPnTab **) tmalloc(numlines * - sizeof(struct INPnTab - *)); + tab->INPtermsymtab = TMALLOC(struct INPnTab *, numlines); ZERO(tab->INPtermsymtab, numlines * sizeof(struct INPnTab *)); tab->INPsize = numlines / 4 + 1; tab->INPtermsize = numlines; @@ -59,7 +56,7 @@ int INPtermInsert(CKTcircuit *ckt, char **token, INPtables * tab, CKTnode **node return (E_EXISTS); } } - t = (struct INPnTab *) tmalloc(sizeof(struct INPnTab)); + t = TMALLOC(struct INPnTab, 1); if (t == (struct INPnTab *) NULL) return (E_NOMEM); ZERO(t, struct INPnTab); @@ -94,7 +91,7 @@ int INPmkTerm(CKTcircuit *ckt, char **token, INPtables * tab, CKTnode **node) return (E_EXISTS); } } - t = (struct INPnTab *) tmalloc(sizeof(struct INPnTab)); + t = TMALLOC(struct INPnTab, 1); if (t == (struct INPnTab *) NULL) return (E_NOMEM); ZERO(t, struct INPnTab); @@ -123,7 +120,7 @@ int INPgndInsert(CKTcircuit *ckt, char **token, INPtables * tab, CKTnode **node) return (E_EXISTS); } } - t = (struct INPnTab *) tmalloc(sizeof(struct INPnTab)); + t = TMALLOC(struct INPnTab, 1); if (t == (struct INPnTab *) NULL) return (E_NOMEM); ZERO(t, struct INPnTab); @@ -169,7 +166,7 @@ int INPinsert(char **token, INPtables * tab) *token = t->t_ent; return (E_EXISTS); } - t = (struct INPtab *) tmalloc(sizeof(struct INPtab)); + t = TMALLOC(struct INPtab, 1); if (t == (struct INPtab *) NULL) return (E_NOMEM); ZERO(t, struct INPtab); @@ -196,7 +193,7 @@ int INPinsertNofree(char **token, INPtables * tab) *token = t->t_ent; return (E_EXISTS); } - t = (struct INPtab *) tmalloc(sizeof(struct INPtab)); + t = TMALLOC(struct INPtab, 1); if (t == (struct INPtab *) NULL) return (E_NOMEM); ZERO(t, struct INPtab); diff --git a/src/tclspice.c b/src/tclspice.c index 951fb6a23..a42592214 100755 --- a/src/tclspice.c +++ b/src/tclspice.c @@ -305,7 +305,7 @@ void blt_init(void *run) { /* initilise */ cur_run = (runDesc *)run; - vectors = (vector *)MALLOC(cur_run->numData*sizeof(vector)); + vectors = TMALLOC(vector, cur_run->numData); for(i = 0;i < cur_run->numData;i++){ vectors[i].name = copy((cur_run->data[i]).name); #ifdef HAVE_LIBPTHREAD @@ -329,7 +329,7 @@ void blt_add(int index,double value){ #endif if(!(v->length < v->size)){ v->size += 100; - v->data = (double *)REALLOC(v->data,sizeof(double)*v->size); + v->data = TREALLOC(double, v->data, v->size); } v->data[v->length] = value; v->length ++; @@ -386,7 +386,7 @@ static int lastVector TCL_CMDPROCARGS(clientData,interp,argc,argv) { Tcl_AppendResult(interp, (char *)blt, TCL_STATIC); return TCL_ERROR; } - if(!(V = (double *)MALLOC(sizeof(double)*blt_vnum))) { + if(!(V = TMALLOC(double, blt_vnum))) { Tcl_SetResult(interp, "Out of Memory",TCL_STATIC); return TCL_ERROR; } @@ -503,13 +503,13 @@ static int vectoblt TCL_CMDPROCARGS(clientData,interp,argc,argv) { Tcl_AppendResult(interp, (char *)var, TCL_STATIC); } else{ - realData = (double *)tmalloc(sizeof(double)*(var_dvec->v_length)); + realData = TMALLOC(double, var_dvec->v_length); for (compIndex=0; compIndexv_length; compIndex++){ realData[compIndex] = ((var_dvec->v_compdata+compIndex)->cx_real); } Blt_ResetVector(real_BltVector, realData, var_dvec->v_length, var_dvec->v_length, TCL_VOLATILE); if (imag_BltVector != NULL) { - compData = (double *)tmalloc(sizeof(double)*(var_dvec->v_length)); + compData = TMALLOC(double, var_dvec->v_length); for (compIndex=0; compIndexv_length; compIndex++){ compData[compIndex] = ((var_dvec->v_compdata+compIndex)->cx_imag); } @@ -520,7 +520,7 @@ static int vectoblt TCL_CMDPROCARGS(clientData,interp,argc,argv) { { Blt_ResetVector(real_BltVector, var_dvec->v_realdata, var_dvec->v_length, var_dvec->v_length, TCL_VOLATILE); if (imag_BltVector != NULL) { - compData = (double *)tmalloc(sizeof(double)*(var_dvec->v_length)); + compData = TMALLOC(double, var_dvec->v_length); for (compIndex=0; compIndexv_length; compIndex++){ compData[compIndex] = 0; } @@ -1482,7 +1482,7 @@ static void dvecToBlt(Blt_Vector *Data, struct dvec *x) { double *data; int i; - data = (double*) tmalloc(x->v_length * sizeof(double)); + data = TMALLOC(double, x->v_length); for(i=0;iv_length;i++) { data[i] = realpart(&x->v_compdata[i]); @@ -1706,7 +1706,7 @@ int Tcl_ExecutePerLoop() { if((current->type > 0 && current->state && v->data[v->length-1] > current->Vmax) || (current->type < 0 && current->state && v->data[v->length-1] < current->Vmin) ) { - struct triggerEvent *tmp = (struct triggerEvent *)MALLOC(sizeof(struct triggerEvent)); + struct triggerEvent *tmp = TMALLOC(struct triggerEvent, 1); tmp->next = NULL; @@ -1954,7 +1954,7 @@ static int registerTrigger TCL_CMDPROCARGS(clientData,interp,argc,argv){ if(tmp == NULL) { - tmp = (struct watch *)MALLOC(sizeof(struct watch)); + tmp = TMALLOC(struct watch, 1); tmp->next = watches; watches = tmp; @@ -2223,7 +2223,7 @@ int Spice_Init(Tcl_Interp *interp) { #ifdef HAVE_ASPRINTF asprintf(&s, "%s%s", pw->pw_dir,INITSTR); #else /* ~ HAVE_ASPRINTF */ - s=(char *) tmalloc(1 + strlen(pw->pw_dir)+strlen(INITSTR)); + s = TMALLOC(char, 1 + strlen(pw->pw_dir) + strlen(INITSTR)); sprintf(s,"%s%s",pw->pw_dir,INITSTR); #endif /* HAVE_ASPRINTF */ if (access(s, 0) == 0) diff --git a/src/unsupported/sen2setp.c b/src/unsupported/sen2setp.c index 7bd66cc32..afdc830fe 100644 --- a/src/unsupported/sen2setp.c +++ b/src/unsupported/sen2setp.c @@ -40,20 +40,14 @@ SENsetParm(ckt,anal,which,value) case SEN_DEV: ((SENstruct *)anal)->SENnumVal += 1; if( ! ((SENstruct *)anal)->SENdevices ) { - ((SENstruct *)anal)->SENdevices = (char **) - MALLOC( ((SENstruct *)anal)->SENnumVal * sizeof(char *)); + ((SENstruct *)anal)->SENdevices = TMALLOC(char *, ((SENstruct *)anal)->SENnumVal); if( ((SENstruct *)anal)->SENdevices == NULL) return(E_NOMEM); - ((SENstruct *)anal)->SENparmNames = (char **) - MALLOC( ((SENstruct *)anal)->SENnumVal * sizeof(char *)); + ((SENstruct *)anal)->SENparmNames = TMALLOC(char *, ((SENstruct *)anal)->SENnumVal); if( ((SENstruct *)anal)->SENparmNames == NULL) return(E_NOMEM); } else { - ((SENstruct *)anal)->SENdevices = (char **) - REALLOC( ((SENstruct *)anal)->SENdevices , - ((SENstruct *)anal)->SENnumVal * sizeof(char *)); + ((SENstruct *)anal)->SENdevices = TREALLOC(char *, ((SENstruct *)anal)->SENdevices, ((SENstruct *)anal)->SENnumVal); if( ((SENstruct *)anal)->SENdevices == NULL) return(E_NOMEM); - ((SENstruct *)anal)->SENparmNames = (char **) REALLOC( - ((SENstruct *)anal)->SENparmNames, - ((SENstruct *)anal)->SENnumVal * sizeof(char *)) ; + ((SENstruct *)anal)->SENparmNames = TREALLOC(char *, ((SENstruct *)anal)->SENparmNames, ((SENstruct *)anal)->SENnumVal) ; if( ((SENstruct *)anal)->SENparmNames == NULL) return(E_NOMEM); } *(((SENstruct *)anal)->SENdevices+((SENstruct *)anal)->SENnumVal-1)= diff --git a/src/xspice/cm/cm.c b/src/xspice/cm/cm.c index 34c31af71..2032be474 100755 --- a/src/xspice/cm/cm.c +++ b/src/xspice/cm/cm.c @@ -107,12 +107,11 @@ void cm_analog_alloc( /* Allocate space in instance struct for this state descriptor */ if(here->num_state == 0) { here->num_state = 1; - here->state = (Mif_State_t *) MALLOC(sizeof(Mif_State_t)); + here->state = TMALLOC(Mif_State_t, 1); } else { here->num_state++; - here->state = (Mif_State_t *) REALLOC(here->state, - here->num_state * sizeof(Mif_State_t)); + here->state = TREALLOC(Mif_State_t, here->state, here->num_state); } /* Fill in the members of the state descriptor struct */ @@ -127,10 +126,9 @@ void cm_analog_alloc( ckt->CKTnumStates += doubles_needed; for(i=0;i<=ckt->CKTmaxOrder+1;i++) { if(ckt->CKTnumStates == doubles_needed) - ckt->CKTstates[i] = (double *) MALLOC(ckt->CKTnumStates * sizeof(double)); + ckt->CKTstates[i] = TMALLOC(double, ckt->CKTnumStates); else - ckt->CKTstates[i] = (double *) REALLOC(ckt->CKTstates[i], - ckt->CKTnumStates * sizeof(double)); + ckt->CKTstates[i] = TREALLOC(double, ckt->CKTstates[i], ckt->CKTnumStates); } } @@ -279,12 +277,11 @@ int cm_analog_integrate( if(! got_index) { if(here->num_intgr == 0) { here->num_intgr = 1; - here->intgr = (Mif_Intgr_t *) MALLOC(sizeof(Mif_Intgr_t)); + here->intgr = TMALLOC(Mif_Intgr_t, 1); } else { here->num_intgr++; - here->intgr = (Mif_Intgr_t *) REALLOC(here->intgr, - here->num_intgr * sizeof(Mif_Intgr_t)); + here->intgr = TREALLOC(Mif_Intgr_t, here->intgr, here->num_intgr); } intgr = &(here->intgr[here->num_intgr - 1]); intgr->byte_index = byte_index; @@ -361,12 +358,11 @@ int cm_analog_converge( /* Allocate space in instance struct for this conv descriptor */ if(here->num_conv == 0) { here->num_conv = 1; - here->conv = (Mif_Conv_t *) MALLOC(sizeof(Mif_Conv_t)); + here->conv = TMALLOC(Mif_Conv_t, 1); } else { here->num_conv++; - here->conv = (Mif_Conv_t *) REALLOC(here->conv, - here->num_conv * sizeof(Mif_Conv_t)); + here->conv = TREALLOC(Mif_Conv_t, here->conv, here->num_conv); } /* Fill in the conv descriptor data */ diff --git a/src/xspice/cm/cmevt.c b/src/xspice/cm/cmevt.c index df4c5dca8..e3fdb113f 100755 --- a/src/xspice/cm/cmevt.c +++ b/src/xspice/cm/cmevt.c @@ -115,7 +115,7 @@ void cm_event_alloc( /* Create a new state description structure at end of list */ /* and fill in the data and update the total size */ - *desc_ptr = (Evt_State_Desc_t *) MALLOC(sizeof(Evt_State_Desc_t)); + *desc_ptr = TMALLOC(Evt_State_Desc_t, 1); desc = *desc_ptr; desc->tag = tag; desc->size = bytes; @@ -125,7 +125,7 @@ void cm_event_alloc( /* Create a new state structure if list starting at head is null */ state = state_data->head[inst_index]; if(state == NULL) { - state = (Evt_State_t *) MALLOC(sizeof(Evt_State_t)); + state = TMALLOC(Evt_State_t, 1); state_data->head[inst_index] = state; } diff --git a/src/xspice/enh/enhtrans.c b/src/xspice/enh/enhtrans.c index 110ec6072..ef21e937f 100755 --- a/src/xspice/enh/enhtrans.c +++ b/src/xspice/enh/enhtrans.c @@ -137,7 +137,7 @@ struct line * ENHtranslate_poly( d->li_error = two2three_translate(d->li_line, &(l1->li_line), &(l2->li_line)); /* Comment out the original line */ - card = (char *) MALLOC(strlen(d->li_line) + 2); + card = TMALLOC(char, strlen(d->li_line) + 2); strcpy(card,"*"); strcat(card, d->li_line); d->li_line = card; @@ -365,7 +365,7 @@ static char *two2three_translate( name = MIFgettok(&card); /* Get output connections (2 netnames) */ - out_conn = (char **) MALLOC(2 * sizeof(char *)); + out_conn = TMALLOC(char *, 2); for(i = 0; i < 2; i++) out_conn[i] = MIFgettok(&card); @@ -383,12 +383,12 @@ static char *two2three_translate( /* Get input connections (2 netnames per dimension) */ - in_conn = (char **) MALLOC(num_conns * sizeof(char *)); + in_conn = TMALLOC(char *, num_conns); for(i = 0; i < num_conns; i++) in_conn[i] = MIFgettok(&card); /* The remainder of the line are the poly coeffs. */ - coef = (char **) MALLOC(num_coefs * sizeof(char *)); + coef = TMALLOC(char *, num_coefs); for(i = 0; i < num_coefs; i++) coef[i] = MIFgettok(&card); @@ -411,8 +411,8 @@ static char *two2three_translate( /* Allocate space for the cards and write them into the strings */ - *inst_card = (char *) MALLOC(inst_card_len); - *mod_card = (char *) MALLOC(mod_card_len); + *inst_card = TMALLOC(char, inst_card_len); + *mod_card = TMALLOC(char, mod_card_len); strcpy(*inst_card, "a$poly$"); sprintf(*inst_card + strlen(*inst_card), "%s ", name); diff --git a/src/xspice/evt/evtdump.c b/src/xspice/evt/evtdump.c index d38a21e47..e4c431e69 100755 --- a/src/xspice/evt/evtdump.c +++ b/src/xspice/evt/evtdump.c @@ -170,7 +170,7 @@ void EVTdump( if(firstcall) { /* Allocate local data structure used to process nodes */ - node_dict = (evtdump_dict_t *) MALLOC(num_nodes * sizeof(evtdump_dict_t)); + node_dict = TMALLOC(evtdump_dict_t, num_nodes); /* Loop through all nodes to determine which nodes should be sent. */ /* Only nodes not within subcircuits qualify. */ diff --git a/src/xspice/evt/evtinit.c b/src/xspice/evt/evtinit.c index 474a3f021..b8e8d5c01 100755 --- a/src/xspice/evt/evtinit.c +++ b/src/xspice/evt/evtinit.c @@ -63,7 +63,7 @@ static int EVTinit_limits(CKTcircuit *ckt); /* Adapted from SPICE 3C1 code in CKTsetup.c */ #define CKALLOC(var,size,type) \ if(size) { \ - if(!(var = (type *) MALLOC((size) * sizeof(type)))) \ + if(!(var = TMALLOC(type, size))) \ return(E_NOMEM); \ } @@ -106,7 +106,7 @@ int EVTinit( /* Will probably remove this restriction later... */ /* if(ckt->evt->counts.num_hybrids == 0) { - errMsg = (char*) MALLOC(strlen(err_no_hybrids) + 1); + errMsg = TMALLOC(char, strlen(err_no_hybrids) + 1); strcpy(errMsg, err_no_hybrids); return(E_PRIVATE); } @@ -219,8 +219,7 @@ static int EVTcheck_nodes( analog_node = ckt->CKTnodes; while(analog_node) { if(strcmp(event_node->name, analog_node->name) == 0) { - errMsg = (char *) MALLOC(strlen(err_prefix) + strlen(event_node->name) + - strlen(err_collide) + 1); + errMsg = TMALLOC(char, strlen(err_prefix) + strlen(event_node->name) + strlen(err_collide) + 1); sprintf(errMsg, "%s%s%s", err_prefix, event_node->name, err_collide); diff --git a/src/xspice/evt/evtiter.c b/src/xspice/evt/evtiter.c index 4093fbf97..bdefb399e 100755 --- a/src/xspice/evt/evtiter.c +++ b/src/xspice/evt/evtiter.c @@ -278,7 +278,7 @@ int EVTiter( /* Too many passes through loop, report problems and exit with error */ - err_msg = (char *) MALLOC(10000); + err_msg = TMALLOC(char, 10000); for(i = 0; i < output_queue->num_changed; i++) { output_index = output_queue->changed_index[i]; port_index = output_table[output_index]->port_index; diff --git a/src/xspice/evt/evtload.c b/src/xspice/evt/evtload.c index be4f11c72..3e4b0ac9a 100755 --- a/src/xspice/evt/evtload.c +++ b/src/xspice/evt/evtload.c @@ -345,7 +345,7 @@ static void EVTcreate_state( else { - new_state = (Evt_State_t *) MALLOC(sizeof(Evt_State_t)); + new_state = TMALLOC(Evt_State_t, 1); new_state->block = tmalloc((size_t) total_size); } @@ -395,7 +395,7 @@ static void EVTcreate_output_event( } else { /* Create a new event */ - event = (Evt_Output_Event_t *) MALLOC(sizeof(Evt_Output_Event_t)); + event = TMALLOC(Evt_Output_Event_t, 1); event->next = NULL; /* Initialize the value */ @@ -447,7 +447,7 @@ static void EVTadd_msg( msg_data->free[port_index] = msg_data->free[port_index]->next; } else { - *msg_ptr = (Evt_Msg_t *) MALLOC(sizeof(Evt_Msg_t)); + *msg_ptr = TMALLOC(Evt_Msg_t, 1); } /* Fill in the values */ diff --git a/src/xspice/evt/evtnode_copy.c b/src/xspice/evt/evtnode_copy.c index 4ac29c3cd..dde0a0558 100755 --- a/src/xspice/evt/evtnode_copy.c +++ b/src/xspice/evt/evtnode_copy.c @@ -114,12 +114,12 @@ void EVTnode_copy( } else { - here = (Evt_Node_t *) MALLOC(sizeof(Evt_Node_t)); + here = TMALLOC(Evt_Node_t, 1); *to = here; /* Allocate/initialize the data in the new node struct */ if(num_outputs > 1) { - here->output_value = (void **) MALLOC(num_outputs * sizeof(void *)); + here->output_value = TMALLOC(void *, num_outputs); for(i = 0; i < num_outputs; i++) { diff --git a/src/xspice/evt/evtop.c b/src/xspice/evt/evtop.c index 442794c04..4760c47e8 100755 --- a/src/xspice/evt/evtop.c +++ b/src/xspice/evt/evtop.c @@ -178,7 +178,7 @@ int EVTop( "Too many analog/event-driven solution alternations", (IFuid *) NULL); - err_msg = (char *) MALLOC(10000); + err_msg = TMALLOC(char, 10000); output_queue = &(ckt->evt->queue.output); output_table = ckt->evt->info.output_table; port_table = ckt->evt->info.port_table; diff --git a/src/xspice/evt/evtplot.c b/src/xspice/evt/evtplot.c index 351b0f336..18e0749dc 100755 --- a/src/xspice/evt/evtplot.c +++ b/src/xspice/evt/evtplot.c @@ -162,8 +162,8 @@ struct dvec *EVTfindvec( num_events++; /* Allocate arrays to hold the analysis point and node value vectors */ - anal_point_vec = (double *) MALLOC(2 * (num_events + 2) * sizeof(double)); - value_vec = (double *) MALLOC(2 * (num_events + 2) * sizeof(double)); + anal_point_vec = TMALLOC(double, 2 * (num_events + 2)); + value_vec = TMALLOC(double, 2 * (num_events + 2)); /* Iterate through the events and fill the arrays. */ /* Note that we create vertical segments every time an event occurs. */ @@ -194,7 +194,7 @@ struct dvec *EVTfindvec( /* Allocate dvec structures and assign the vectors into them. */ /* See FTE/OUTinterface.c:plotInit() for initialization example. */ - scale = (struct dvec *) MALLOC(sizeof(struct dvec)); + scale = TMALLOC(struct dvec, 1); scale->v_name = MIFcopy("step"); scale->v_type = SV_TIME; @@ -203,7 +203,7 @@ struct dvec *EVTfindvec( scale->v_realdata = anal_point_vec; scale->v_scale = NULL; - d = (struct dvec *) MALLOC(sizeof(struct dvec)); + d = TMALLOC(struct dvec, 1); d->v_name = name; d->v_type = SV_VOLTAGE; diff --git a/src/xspice/evt/evtqueue.c b/src/xspice/evt/evtqueue.c index 4f8e46700..58ec2e5e8 100755 --- a/src/xspice/evt/evtqueue.c +++ b/src/xspice/evt/evtqueue.c @@ -204,7 +204,7 @@ void EVTqueue_inst( inst_queue->free[inst_index] = new_event->next; } else { - new_event = (Evt_Inst_Event_t *) MALLOC(sizeof(Evt_Inst_Event_t)); + new_event = TMALLOC(Evt_Inst_Event_t, 1); } new_event->event_time = event_time; new_event->posted_time = posted_time; diff --git a/src/xspice/evt/evtsetup.c b/src/xspice/evt/evtsetup.c index d1d803721..683998e10 100755 --- a/src/xspice/evt/evtsetup.c +++ b/src/xspice/evt/evtsetup.c @@ -72,16 +72,16 @@ static int EVTsetup_load_ptrs(CKTcircuit *ckt); #define CKALLOC(var,size,type) \ if(size) { \ - if(!(var = (type *) MALLOC((size) * sizeof(type)))) \ + if(!(var = TMALLOC(type, size))) \ return(E_NOMEM); \ } #define CKREALLOC(var,size,type) \ if((size) == 1) { \ - if(!(var = (type *) MALLOC((size) * sizeof(type)))) \ + if(!(var = TMALLOC(type, size))) \ return(E_NOMEM); \ } else if((size) > 1) { \ - if(!(var = (type *) REALLOC((void *) (var), (size) * sizeof(type)))) \ + if(!(var = TREALLOC(type, (var), size))) \ return(E_NOMEM); \ } diff --git a/src/xspice/evt/evttermi.c b/src/xspice/evt/evttermi.c index 529f420b3..62bcb1577 100755 --- a/src/xspice/evt/evttermi.c +++ b/src/xspice/evt/evttermi.c @@ -212,7 +212,7 @@ static void EVTinst_insert( /* If not found, create a new entry in list and increment the */ /* instance count in the event structure */ if(! found) { - *inst_ptr = (Evt_Inst_Info_t *) MALLOC(sizeof(Evt_Inst_Info_t)); + *inst_ptr = TMALLOC(Evt_Inst_Info_t, 1); inst = *inst_ptr; inst->next = NULL; inst->inst_ptr = fast; @@ -325,7 +325,7 @@ static void EVTnode_insert( /* If not found, create a new entry in list and increment the */ /* node count in the event structure */ if(! found) { - *node_ptr = (Evt_Node_Info_t *) MALLOC(sizeof(Evt_Node_Info_t)); + *node_ptr = TMALLOC(Evt_Node_Info_t, 1); node = *node_ptr; node->next = NULL; node->name = MIFcopy(node_name); @@ -370,7 +370,7 @@ static void EVTnode_insert( if(! found) { (node->num_insts)++; - *inst_ptr = (Evt_Inst_Index_t *) MALLOC(sizeof(Evt_Inst_Index_t)); + *inst_ptr = TMALLOC(Evt_Inst_Index_t, 1); inst = *inst_ptr; inst->next = NULL; inst->index = inst_index; @@ -431,7 +431,7 @@ static void EVTport_insert( (ckt->evt->counts.num_ports)++; - *port_ptr = (Evt_Port_Info_t *) MALLOC(sizeof(Evt_Port_Info_t)); + *port_ptr = TMALLOC(Evt_Port_Info_t, 1); port = *port_ptr; /* Fill in the elements */ @@ -493,7 +493,7 @@ static void EVToutput_insert( (ckt->evt->counts.num_outputs)++; - *output_ptr = (Evt_Output_Info_t *) MALLOC(sizeof(Evt_Output_Info_t)); + *output_ptr = TMALLOC(Evt_Output_Info_t, 1); output = *output_ptr; /* Fill in the elements */ diff --git a/src/xspice/icm/xtraevt/int/udnfunc.c b/src/xspice/icm/xtraevt/int/udnfunc.c index 198535074..2f3aa28ca 100644 --- a/src/xspice/icm/xtraevt/int/udnfunc.c +++ b/src/xspice/icm/xtraevt/int/udnfunc.c @@ -46,6 +46,7 @@ NON-STANDARD FEATURES void *tmalloc(size_t); +#define TMALLOC(t,n) (t*) /**/ tmalloc(sizeof(t) * (size_t)(n)) /* ************************************************************************ */ @@ -53,7 +54,7 @@ void *tmalloc(size_t); static void udn_int_create(CREATE_ARGS) { /* Malloc space for an int */ - MALLOCED_PTR = (int*) tmalloc(sizeof(int)); + MALLOCED_PTR = TMALLOC(int, 1); } @@ -152,7 +153,7 @@ static void udn_int_print_val(PRINT_VAL_ARGS) int *int_struct = (int *) STRUCT_PTR; /* Allocate space for the printed value */ - PRINT_VAL = (char *) tmalloc(30); + PRINT_VAL = TMALLOC(char, 30); /* Print the value into the string */ sprintf(PRINT_VAL, "%8d", *int_struct); diff --git a/src/xspice/icm/xtraevt/real/udnfunc.c b/src/xspice/icm/xtraevt/real/udnfunc.c index 6d7689bd8..828e06afe 100644 --- a/src/xspice/icm/xtraevt/real/udnfunc.c +++ b/src/xspice/icm/xtraevt/real/udnfunc.c @@ -46,6 +46,7 @@ NON-STANDARD FEATURES void *tmalloc(size_t); +#define TMALLOC(t,n) (t*) /**/ tmalloc(sizeof(t) * (size_t)(n)) /* ************************************************************************ */ @@ -53,7 +54,7 @@ void *tmalloc(size_t); static void udn_real_create(CREATE_ARGS) { /* Malloc space for a real struct */ - MALLOCED_PTR = (double*) tmalloc(sizeof(double)); + MALLOCED_PTR = TMALLOC(double, 1); } @@ -155,7 +156,7 @@ static void udn_real_print_val(PRINT_VAL_ARGS) /* Allocate space for the printed value */ - PRINT_VAL = (char *) tmalloc(30); + PRINT_VAL = TMALLOC(char, 30); /* Print the value into the string */ sprintf(PRINT_VAL, "%15.6e", *real_struct); diff --git a/src/xspice/idn/idndig.c b/src/xspice/idn/idndig.c index fde608a29..45a15c37c 100755 --- a/src/xspice/idn/idndig.c +++ b/src/xspice/idn/idndig.c @@ -51,7 +51,7 @@ static void idn_digital_create(void **evt_struct) { /* Malloc space for a digital struct */ - *evt_struct = (Digital_t*) tmalloc(sizeof(Digital_t)); + *evt_struct = TMALLOC(Digital_t, 1); } diff --git a/src/xspice/ipc/ipctiein.c b/src/xspice/ipc/ipctiein.c index 7fa5ea9c5..18ffb661f 100755 --- a/src/xspice/ipc/ipctiein.c +++ b/src/xspice/ipc/ipctiein.c @@ -159,8 +159,8 @@ void ipc_handle_vtrans( if(g_ipc.vtrans.size == 0) { g_ipc.vtrans.size = 1; - g_ipc.vtrans.vsrc_name = (char **) MALLOC(sizeof(char *)); - g_ipc.vtrans.device_name = (char **) MALLOC(sizeof(char *)); + g_ipc.vtrans.vsrc_name = TMALLOC(char *, 1); + g_ipc.vtrans.device_name = TMALLOC(char *, 1); g_ipc.vtrans.vsrc_name[0] = MIFcopy(vsrc); g_ipc.vtrans.device_name[0] = MIFcopy(dev); } @@ -170,10 +170,8 @@ void ipc_handle_vtrans( size = g_ipc.vtrans.size; i = g_ipc.vtrans.size - 1; - g_ipc.vtrans.vsrc_name = (char **) REALLOC(g_ipc.vtrans.vsrc_name, - size * sizeof(char *)); - g_ipc.vtrans.device_name = (char **) REALLOC(g_ipc.vtrans.device_name, - size * sizeof(char *)); + g_ipc.vtrans.vsrc_name = TREALLOC(char *, g_ipc.vtrans.vsrc_name, size); + g_ipc.vtrans.device_name = TREALLOC(char *, g_ipc.vtrans.device_name, size); g_ipc.vtrans.vsrc_name[i] = MIFcopy(vsrc); g_ipc.vtrans.device_name[i] = MIFcopy(dev); } @@ -423,17 +421,16 @@ int ipc_get_devices( /* Otherwise, add the name to the list */ num_instances++; if(num_instances == 1) - *names = (char **) MALLOC(sizeof(char *)); + *names = TMALLOC(char *, 1); else - *names = (char **) REALLOC(*names, num_instances * sizeof(char *)); + *names = TREALLOC(char *, *names, num_instances); (*names)[num_instances-1] = MIFcopy(inst_name); /* Then get the type if it is a Q J or M */ if(num_instances == 1) - *modtypes = (double *) MALLOC(sizeof(double)); + *modtypes = TMALLOC(double, 1); else - *modtypes = (double *) REALLOC((char *) *modtypes, - num_instances * sizeof(double)); + *modtypes = TREALLOC(double, *modtypes, num_instances); if(strcmp(device,"BJT") == 0) { BJTmod = (BJTmodel *) model; diff --git a/src/xspice/mif/mif_inp2.c b/src/xspice/mif/mif_inp2.c index 5091b25a9..a82b30a67 100755 --- a/src/xspice/mif/mif_inp2.c +++ b/src/xspice/mif/mif_inp2.c @@ -559,10 +559,10 @@ static void MIFinit_inst( /* allocate code model connector data in instance struct */ fast->num_conn = DEVices[mod_type]->DEVpublic.num_conn; - fast->conn = (Mif_Conn_Data_t **) tmalloc(fast->num_conn * sizeof(Mif_Conn_Data_t *)); + fast->conn = TMALLOC(Mif_Conn_Data_t *, fast->num_conn); for(i = 0; i < fast->num_conn; i++) - fast->conn[i] = (Mif_Conn_Data_t *) tmalloc(sizeof(Mif_Conn_Data_t)); + fast->conn[i] = TMALLOC(Mif_Conn_Data_t, 1); /* initialize code model connector data */ for(i = 0; i < fast->num_conn; i++) { @@ -595,11 +595,11 @@ static void MIFinit_inst( /* allocate and copy instance variable data to the instance */ fast->num_inst_var = DEVices[mod_type]->DEVpublic.num_inst_var; - fast->inst_var = (Mif_Inst_Var_Data_t **) tmalloc(fast->num_inst_var * sizeof(Mif_Inst_Var_Data_t *)); + fast->inst_var = TMALLOC(Mif_Inst_Var_Data_t *, fast->num_inst_var); for(i = 0; i < fast->num_inst_var; i++) { - fast->inst_var[i] = (Mif_Inst_Var_Data_t *) tmalloc(sizeof(Mif_Inst_Var_Data_t)); + fast->inst_var[i] = TMALLOC(Mif_Inst_Var_Data_t, 1); if(DEVices[mod_type]->DEVpublic.inst_var[i].is_array) { fast->inst_var[i]->size = 0; @@ -608,7 +608,7 @@ static void MIFinit_inst( } else { fast->inst_var[i]->size = 1; - fast->inst_var[i]->element = (Mif_Value_t *) tmalloc(sizeof(Mif_Value_t)); + fast->inst_var[i]->element = TMALLOC(Mif_Value_t, 1); } } @@ -769,14 +769,12 @@ MIFget_port( /* allocate space in the instance data struct for this port */ if(port_num == 0) { - fast->conn[conn_num]->port = (Mif_Port_Data_t **) tmalloc(sizeof(Mif_Port_Data_t *)); - fast->conn[conn_num]->port[0] = (Mif_Port_Data_t *) tmalloc(sizeof(Mif_Port_Data_t)); + fast->conn[conn_num]->port = TMALLOC(Mif_Port_Data_t *, 1); + fast->conn[conn_num]->port[0] = TMALLOC(Mif_Port_Data_t, 1); } else { - fast->conn[conn_num]->port = (Mif_Port_Data_t **) REALLOC( - fast->conn[conn_num]->port, - (port_num + 1) * sizeof(Mif_Port_Data_t *) ); - fast->conn[conn_num]->port[port_num] = (Mif_Port_Data_t *) tmalloc(sizeof(Mif_Port_Data_t)); + fast->conn[conn_num]->port = TREALLOC(Mif_Port_Data_t *, fast->conn[conn_num]->port, port_num + 1); + fast->conn[conn_num]->port[port_num] = TMALLOC(Mif_Port_Data_t, 1); } @@ -913,7 +911,7 @@ MIFget_port( /* These are single ended types, so default other node to ground */ // This don't work dickhead, INPtermInsert tries to FREE(&node) K.A. Feb 27, 2000 // which was not allocted - node = (char*)tmalloc(2);// added by K.A. march 5th 2000 + node = TMALLOC(char, 2);// added by K.A. march 5th 2000 *node = '0'; // added by K.A. March 5th 2000 node[1] ='\0'; // added by K.A. March 5th 2000 diff --git a/src/xspice/mif/mifask.c b/src/xspice/mif/mifask.c index 3f3bb1a52..ed4c06b4b 100755 --- a/src/xspice/mif/mifask.c +++ b/src/xspice/mif/mifask.c @@ -169,7 +169,7 @@ int MIFask( case IF_FLAGVEC: if(size <= 0) break; - value->v.vec.iVec = (int *) MALLOC(size * sizeof(int)); + value->v.vec.iVec = TMALLOC(int, size); for(i = 0; i < size; i++) value->v.vec.iVec[i] = inst->inst_var[inst_index]->element[i].bvalue; break; @@ -177,7 +177,7 @@ int MIFask( case IF_INTVEC: if(size <= 0) break; - value->v.vec.iVec = (int *) MALLOC(size * sizeof(int)); + value->v.vec.iVec = TMALLOC(int, size); for(i = 0; i < size; i++) value->v.vec.iVec[i] = inst->inst_var[inst_index]->element[i].ivalue; break; @@ -185,7 +185,7 @@ int MIFask( case IF_REALVEC: if(size <= 0) break; - value->v.vec.rVec = (double *) MALLOC(size * sizeof(double)); + value->v.vec.rVec = TMALLOC(double, size); for(i = 0; i < size; i++) value->v.vec.rVec[i] = inst->inst_var[inst_index]->element[i].rvalue; break; @@ -193,7 +193,7 @@ int MIFask( case IF_STRINGVEC: if(size <= 0) break; - value->v.vec.sVec = (char **) MALLOC(size * sizeof(char *)); + value->v.vec.sVec = TMALLOC(char *, size); for(i = 0; i < size; i++) /* Make copy of string. We don't trust caller to not free it */ /* These copies could get expensive! */ @@ -205,7 +205,7 @@ int MIFask( break; /* we don't trust the caller to have a parallel complex structure */ /* so copy the real and imaginary parts explicitly */ - value->v.vec.cVec = (IFcomplex *) MALLOC(size * sizeof(IFcomplex)); + value->v.vec.cVec = TMALLOC(IFcomplex, size); for(i = 0; i < size; i++) { value->v.vec.cVec[i].real = inst->inst_var[inst_index]->element[i].cvalue.real; value->v.vec.cVec[i].imag = inst->inst_var[inst_index]->element[i].cvalue.imag; diff --git a/src/xspice/mif/mifgetmod.c b/src/xspice/mif/mifgetmod.c index f661bf05e..9fa8ecef7 100755 --- a/src/xspice/mif/mifgetmod.c +++ b/src/xspice/mif/mifgetmod.c @@ -151,7 +151,7 @@ char *MIFgetMod( /* fixed by SDB -- magic number is 39, not 35. * Also needed parens to correctly compute # of bytes to malloc */ - err = (char *)tmalloc( (39+strlen(name)) * sizeof(char) ); + err = TMALLOC(char, 39 + strlen(name)); sprintf(err, "MIF: Unknown device type for model %s \n",name); return(err); @@ -169,9 +169,9 @@ char *MIFgetMod( /* gtri modification: allocate and initialize MIF specific model struct items */ mdfast = (MIFmodel*) modtmp->INPmodfast; mdfast->num_param = DEVices[modtmp->INPmodType]->DEVpublic.num_param; - mdfast->param = (Mif_Param_Data_t **) tmalloc(mdfast->num_param * sizeof(Mif_Param_Data_t *)); + mdfast->param = TMALLOC(Mif_Param_Data_t *, mdfast->num_param); for(i = 0; i < mdfast->num_param; i++) { - mdfast->param[i] = (Mif_Param_Data_t *) tmalloc(sizeof(Mif_Param_Data_t)); + mdfast->param[i] = TMALLOC(Mif_Param_Data_t, 1); mdfast->param[i]->is_null = MIF_TRUE; mdfast->param[i]->size = 0; mdfast->param[i]->element = NULL; @@ -199,7 +199,7 @@ char *MIFgetMod( INPmodType ]).modelParms[j]. dataType),tab,&err1); if(err1) { - err2 = (char *) tmalloc(25 + strlen(name) + strlen(err1)); + err2 = TMALLOC(char, 25 + strlen(name) + strlen(err1)); sprintf(err2, "MIF-ERROR - model: %s - %s\n", name, err1); return(err2); } @@ -218,13 +218,13 @@ char *MIFgetMod( //err has not been allocated, but free() in INPerrCat() // This did not allocate enough memory you wanker, K.A. replaced 5 March 2000 - // temp = (char *)tmalloc((40+strlen(parm)) * sizeof(char)); - temp = (char *)tmalloc((42+strlen(parm)) * sizeof(char));// K.A. replaced 5 March 2000 + // temp = TMALLOC(char, 40 + strlen(parm)); + temp = TMALLOC(char, 42 + strlen(parm));// K.A. replaced 5 March 2000 sprintf(temp, "MIF: unrecognized parameter (%s) - ignored\n", parm); fprintf(stdout,temp); - err = (char *)tmalloc( (2*strlen(temp) +2)*sizeof(char));// K.A. added 5 March 2000 + err = TMALLOC(char, 2 * strlen(temp) + 2);// K.A. added 5 March 2000 *err = '\0';// K.A. added 5 March 2000 @@ -249,7 +249,7 @@ char *MIFgetMod( /* didn't find model - ERROR - return NULL model */ *model = (INPmodel *)NULL; - err = (char *)tmalloc((60+strlen(name)) * sizeof(char)); + err = TMALLOC(char, 60 + strlen(name)); sprintf(err, " MIF-ERROR - unable to find definition of model %s\n",name); return(err); diff --git a/src/xspice/mif/mifgetvalue.c b/src/xspice/mif/mifgetvalue.c index aedf969ae..801f1710d 100755 --- a/src/xspice/mif/mifgetvalue.c +++ b/src/xspice/mif/mifgetvalue.c @@ -171,40 +171,35 @@ MIFgetValue ( case IF_FLAGVEC: btemp = MIFget_boolean(token, err); - val.v.vec.iVec = (int *) REALLOC(val.v.vec.iVec, - (val.v.numValue + 1) * sizeof(int)); + val.v.vec.iVec = TREALLOC(int, val.v.vec.iVec, val.v.numValue + 1); val.v.vec.iVec[val.v.numValue] = btemp; val.v.numValue++; break; case IF_INTVEC: itemp = MIFget_integer(token, err); - val.v.vec.iVec = (int *) REALLOC(val.v.vec.iVec, - (val.v.numValue + 1) * sizeof(int)); + val.v.vec.iVec = TREALLOC(int, val.v.vec.iVec, val.v.numValue + 1); val.v.vec.iVec[val.v.numValue] = itemp; val.v.numValue++; break; case IF_REALVEC: rtemp = MIFget_real(token, err); - val.v.vec.rVec = (double *) REALLOC(val.v.vec.rVec, - (val.v.numValue + 1) * sizeof(double)); + val.v.vec.rVec = TREALLOC(double, val.v.vec.rVec, val.v.numValue + 1); val.v.vec.rVec[val.v.numValue] = rtemp; val.v.numValue++; break; case IF_STRINGVEC: stemp = MIFget_string(token, err); - val.v.vec.sVec = (char **) REALLOC(val.v.vec.sVec, - (val.v.numValue + 1) * sizeof(char *)); + val.v.vec.sVec = TREALLOC(char *, val.v.vec.sVec, val.v.numValue + 1); val.v.vec.sVec[val.v.numValue] = stemp; val.v.numValue++; break; case IF_CPLXVEC: ctemp = MIFget_complex(token, token_type, line, err); - val.v.vec.cVec = (IFcomplex *) REALLOC(val.v.vec.cVec, - (val.v.numValue + 1) * sizeof(IFcomplex)); + val.v.vec.cVec = TREALLOC(IFcomplex, val.v.vec.cVec, val.v.numValue + 1); val.v.vec.cVec[val.v.numValue] = ctemp; val.v.numValue++; break; diff --git a/src/xspice/mif/mifmask.c b/src/xspice/mif/mifmask.c index f8d4ced66..4e4ecffe5 100755 --- a/src/xspice/mif/mifmask.c +++ b/src/xspice/mif/mifmask.c @@ -159,7 +159,7 @@ int MIFmAsk( case IF_FLAGVEC: if(size <= 0) break; - value->v.vec.iVec = (int *) MALLOC(size * sizeof(int)); + value->v.vec.iVec = TMALLOC(int, size); for(i = 0; i < size; i++) value->v.vec.iVec[i] = model->param[param_index]->element[i].bvalue; break; @@ -167,7 +167,7 @@ int MIFmAsk( case IF_INTVEC: if(size <= 0) break; - value->v.vec.iVec = (int *) MALLOC(size * sizeof(int)); + value->v.vec.iVec = TMALLOC(int, size); for(i = 0; i < size; i++) value->v.vec.iVec[i] = model->param[param_index]->element[i].ivalue; break; @@ -175,7 +175,7 @@ int MIFmAsk( case IF_REALVEC: if(size <= 0) break; - value->v.vec.rVec = (double *) MALLOC(size * sizeof(double)); + value->v.vec.rVec = TMALLOC(double, size); for(i = 0; i < size; i++) value->v.vec.rVec[i] = model->param[param_index]->element[i].rvalue; break; @@ -183,7 +183,7 @@ int MIFmAsk( case IF_STRINGVEC: if(size <= 0) break; - value->v.vec.sVec = (char **) MALLOC(size * sizeof(char *)); + value->v.vec.sVec = TMALLOC(char *, size); for(i = 0; i < size; i++) /* Make copy of string. We don't trust caller to not free it */ /* These copies could get expensive! */ @@ -195,7 +195,7 @@ int MIFmAsk( break; /* we don't trust the caller to have a parallel complex structure */ /* so copy the real and imaginary parts explicitly */ - value->v.vec.cVec = (IFcomplex *) MALLOC(size * sizeof(IFcomplex)); + value->v.vec.cVec = TMALLOC(IFcomplex, size); for(i = 0; i < size; i++) { value->v.vec.cVec[i].real = model->param[param_index]->element[i].cvalue.real; value->v.vec.cVec[i].imag = model->param[param_index]->element[i].cvalue.imag; diff --git a/src/xspice/mif/mifmpara.c b/src/xspice/mif/mifmpara.c index 9580d443a..5754c62d9 100755 --- a/src/xspice/mif/mifmpara.c +++ b/src/xspice/mif/mifmpara.c @@ -111,12 +111,11 @@ int MIFmParam( model->param[param_index]->is_null = MIF_FALSE; if(is_array) { model->param[param_index]->size = value->v.numValue; - model->param[param_index]->element = (Mif_Value_t *) MALLOC(value->v.numValue * - sizeof(Mif_Value_t)); + model->param[param_index]->element = TMALLOC(Mif_Value_t, value->v.numValue); } else { model->param[param_index]->size = 1; - model->param[param_index]->element = (Mif_Value_t *) MALLOC(sizeof(Mif_Value_t)); + model->param[param_index]->element = TMALLOC(Mif_Value_t, 1); } @@ -143,7 +142,7 @@ int MIFmParam( case IF_STRING: /* we don't trust the caller to keep the string alive, so copy it */ model->param[param_index]->element[0].svalue = - (char *) MALLOC(1 + strlen(value->sValue)); + TMALLOC(char, 1 + strlen(value->sValue)); strcpy(model->param[param_index]->element[0].svalue, value->sValue); break; @@ -180,7 +179,7 @@ int MIFmParam( case IF_STRINGVEC: /* we don't trust the caller to keep the string alive, so copy it */ model->param[param_index]->element[i].svalue = - (char *) MALLOC(1 + strlen(value->v.vec.sVec[i])); + TMALLOC(char, 1 + strlen(value->v.vec.sVec[i])); strcpy(model->param[param_index]->element[i].svalue, value->v.vec.sVec[i]); break; diff --git a/src/xspice/mif/mifsetup.c b/src/xspice/mif/mifsetup.c index 280af0624..67683f409 100755 --- a/src/xspice/mif/mifsetup.c +++ b/src/xspice/mif/mifsetup.c @@ -150,7 +150,7 @@ MIFsetup( /* determine the size and allocate the parameter element(s) */ if(! param_info->is_array) { model->param[i]->size = 1; - model->param[i]->element = (Mif_Value_t *) MALLOC(sizeof(Mif_Value_t)); + model->param[i]->element = TMALLOC(Mif_Value_t, 1); } else { /* parameter is an array */ /* MIF_INP2A() parser assures that there is an associated array connection */ @@ -163,7 +163,7 @@ MIFsetup( max_size = size; } model->param[i]->size = max_size; - model->param[i]->element = (Mif_Value_t *) MALLOC(max_size * sizeof(Mif_Value_t)); + model->param[i]->element = TMALLOC(Mif_Value_t, max_size); } /* end if parameter is an array */ /* set the parameter element(s) to default value */ @@ -232,21 +232,21 @@ MIFsetup( num_port = here->conn[i]->size; for(j = 0; j < num_port; j++) { here->conn[i]->port[j]->partial = - (Mif_Partial_t *) MALLOC(num_conn * sizeof(Mif_Partial_t)); + TMALLOC(Mif_Partial_t, num_conn); here->conn[i]->port[j]->ac_gain = - (Mif_AC_Gain_t *) MALLOC(num_conn * sizeof(Mif_AC_Gain_t)); + TMALLOC(Mif_AC_Gain_t, num_conn); here->conn[i]->port[j]->smp_data.input = - (Mif_Conn_Ptr_t *) MALLOC(num_conn * sizeof(Mif_Conn_Ptr_t)); + TMALLOC(Mif_Conn_Ptr_t, num_conn); for(k = 0; k < num_conn; k++) { if((here->conn[k]->is_null) || (! here->conn[k]->is_input) ) continue; num_port_k = here->conn[k]->size; here->conn[i]->port[j]->partial[k].port = - (double *) MALLOC(num_port_k * sizeof(double)); + TMALLOC(double, num_port_k); here->conn[i]->port[j]->ac_gain[k].port = - (Mif_Complex_t *) MALLOC(num_port_k * sizeof(Mif_Complex_t)); + TMALLOC(Mif_Complex_t, num_port_k); here->conn[i]->port[j]->smp_data.input[k].port = - (Mif_Port_Ptr_t *) MALLOC(num_port_k * sizeof(Mif_Port_Ptr_t)); + TMALLOC(Mif_Port_Ptr_t, num_port_k); } } } @@ -307,7 +307,7 @@ MIFsetup( (type == MIF_RESISTANCE || type == MIF_DIFF_RESISTANCE) ) { /* first, make the current equation */ - suffix = (char *) MALLOC(strlen((char *) here->MIFname) + 100); + suffix = TMALLOC(char, strlen((char *) here->MIFname) + 100); sprintf(suffix, "branch_%d_%d", i, j); error = CKTmkCur(ckt, &tmp, here->MIFname, suffix); FREE(suffix); @@ -330,7 +330,7 @@ MIFsetup( if(is_input && (type == MIF_CURRENT || type == MIF_DIFF_CURRENT)) { /* first, make the current equation */ - suffix = (char *) MALLOC(strlen((char *) here->MIFname) + 100); + suffix = TMALLOC(char, strlen((char *) here->MIFname) + 100); sprintf(suffix, "ibranch_%d_%d", i, j); error = CKTmkCur(ckt, &tmp, here->MIFname, suffix); FREE(suffix); diff --git a/src/xspice/mif/mifutil.c b/src/xspice/mif/mifutil.c index 9b250fef3..4119cdf2a 100755 --- a/src/xspice/mif/mifutil.c +++ b/src/xspice/mif/mifutil.c @@ -76,7 +76,7 @@ char *MIFgettok(char **s) /* allocate space big enough for the whole string */ - buf = (char *) MALLOC(strlen(*s) + 1); + buf = TMALLOC(char, strlen(*s) + 1); /* skip over any white space */