From 4c1c95e20f1cf2a8a6e54229dcd084eea307b12a Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 12 Mar 2016 12:20:16 +0100 Subject: [PATCH] everywhere, use `TMALLOC()' instead of `alloc()' --- src/frontend/aspice.c | 2 +- src/frontend/breakp.c | 6 +++--- src/frontend/breakp2.c | 2 +- src/frontend/com_alias.c | 6 +++--- src/frontend/com_history.c | 4 ++-- src/frontend/control.c | 6 +++--- src/frontend/define.c | 2 +- src/frontend/help/readhelp.c | 6 +++--- src/frontend/inp.c | 4 ++-- src/frontend/measure.c | 2 +- src/frontend/options.c | 18 +++++++++--------- src/frontend/outitf.c | 2 +- src/frontend/parse.c | 2 +- src/frontend/parser/complete.c | 8 ++++---- src/frontend/parser/unixcom.c | 2 +- src/frontend/rawfile.c | 2 +- src/frontend/spiceif.c | 4 ++-- src/frontend/subckt.c | 6 +++--- src/frontend/variable.c | 12 ++++++------ src/frontend/vectors.c | 2 +- src/include/ngspice/memory.h | 1 - src/misc/wlist.c | 4 ++-- src/ngsconvert.c | 2 +- src/xspice/enh/enhtrans.c | 4 ++-- 24 files changed, 54 insertions(+), 55 deletions(-) diff --git a/src/frontend/aspice.c b/src/frontend/aspice.c index 276a9a673..d5828d620 100644 --- a/src/frontend/aspice.c +++ b/src/frontend/aspice.c @@ -131,7 +131,7 @@ com_aspice(wordlist *wl) } /* Add this one to the job list. */ - p = alloc(struct proc); + p = TMALLOC(struct proc, 1); p->pr_pid = pid; p->pr_name = copy(s); p->pr_rawfile = copy(raw); diff --git a/src/frontend/breakp.c b/src/frontend/breakp.c index 06657831e..c2ab7ea71 100644 --- a/src/frontend/breakp.c +++ b/src/frontend/breakp.c @@ -44,9 +44,9 @@ com_stop(wordlist *wl) while (wl) { if (thisone == NULL) { - thisone = d = alloc(struct dbcomm); + thisone = d = TMALLOC(struct dbcomm, 1); } else { - d->db_also = alloc(struct dbcomm); + d->db_also = TMALLOC(struct dbcomm, 1); d = d->db_also; } @@ -180,7 +180,7 @@ com_iplot(wordlist *wl) separate iplot commands. */ while (wl) { s = cp_unquote(wl->wl_word); - d = alloc(struct dbcomm); + d = TMALLOC(struct dbcomm, 1); d->db_analysis = NULL; d->db_number = debugnumber++; if (eq(s, "all")) { diff --git a/src/frontend/breakp2.c b/src/frontend/breakp2.c index 7e85255bb..ee1e19e6a 100644 --- a/src/frontend/breakp2.c +++ b/src/frontend/breakp2.c @@ -54,7 +54,7 @@ settrace(wordlist *wl, int what, char *name) while (wl) { s = cp_unquote(wl->wl_word); - d = alloc(struct dbcomm); + d = TMALLOC(struct dbcomm, 1); d->db_number = debugnumber++; d->db_analysis = name; if (eq(s, "all")) { diff --git a/src/frontend/com_alias.c b/src/frontend/com_alias.c index 86a0b3989..2aa4cbf1a 100644 --- a/src/frontend/com_alias.c +++ b/src/frontend/com_alias.c @@ -123,7 +123,7 @@ cp_setalias(char *word, wordlist *wlist) cp_addkword(CT_ALIASES, word); if (cp_aliases == NULL) { - al = cp_aliases = alloc(struct alias); + al = cp_aliases = TMALLOC(struct alias, 1); al->al_next = NULL; al->al_prev = NULL; } else { @@ -135,13 +135,13 @@ cp_setalias(char *word, wordlist *wlist) if (al->al_prev) { al = al->al_prev; ta = al->al_next; - al->al_next = alloc(struct alias); + al->al_next = TMALLOC(struct alias, 1); al->al_next->al_prev = al; al = al->al_next; al->al_next = ta; ta->al_prev = al; } else { - cp_aliases = alloc(struct alias); + cp_aliases = TMALLOC(struct alias, 1); cp_aliases->al_next = al; cp_aliases->al_prev = NULL; al->al_prev = cp_aliases; diff --git a/src/frontend/com_history.c b/src/frontend/com_history.c index 07ed2a3bc..f994d22d6 100644 --- a/src/frontend/com_history.c +++ b/src/frontend/com_history.c @@ -364,10 +364,10 @@ cp_addhistent(int event, wordlist *wlist) /* MW. the begging - initialize histlength */ histlength = 1; - cp_lastone = histlist = alloc(struct histent); + cp_lastone = histlist = TMALLOC(struct histent, 1); cp_lastone->hi_prev = NULL; } else { - cp_lastone->hi_next = alloc(struct histent); + cp_lastone->hi_next = TMALLOC(struct histent, 1); cp_lastone->hi_next->hi_prev = cp_lastone; cp_lastone = cp_lastone->hi_next; } diff --git a/src/frontend/control.c b/src/frontend/control.c index ba684060e..dda256e97 100644 --- a/src/frontend/control.c +++ b/src/frontend/control.c @@ -620,7 +620,7 @@ cp_evloop(char *string) #define newblock \ do { \ - cend[stackp]->co_children = alloc(struct control); \ + cend[stackp]->co_children = TMALLOC(struct control, 1); \ ZERO(cend[stackp]->co_children, struct control); \ cend[stackp]->co_children->co_parent = cend[stackp]; \ cend[stackp] = cend[stackp]->co_children; \ @@ -663,13 +663,13 @@ cp_evloop(char *string) */ /* va: TODO: free old structure and its content, before overwriting */ if (cend[stackp] && (cend[stackp]->co_type != CO_UNFILLED)) { - cend[stackp]->co_next = alloc(struct control); + cend[stackp]->co_next = TMALLOC(struct control, 1); ZERO(cend[stackp]->co_next, struct control); cend[stackp]->co_next->co_prev = cend[stackp]; cend[stackp]->co_next->co_parent = cend[stackp]->co_parent; cend[stackp] = cend[stackp]->co_next; } else if (!cend[stackp]) { - control[stackp] = cend[stackp] = alloc(struct control); + control[stackp] = cend[stackp] = TMALLOC(struct control, 1); ZERO(cend[stackp], struct control); } diff --git a/src/frontend/define.c b/src/frontend/define.c index 51c88e13b..c97750d18 100644 --- a/src/frontend/define.c +++ b/src/frontend/define.c @@ -135,7 +135,7 @@ com_define(wordlist *wlist) break; if (udf == NULL) { - udf = alloc(struct udfunc); + udf = TMALLOC(struct udfunc, 1); udf->ud_next = udfuncs; udfuncs = udf; } diff --git a/src/frontend/help/readhelp.c b/src/frontend/help/readhelp.c index 15ec41e6c..1828885b1 100644 --- a/src/frontend/help/readhelp.c +++ b/src/frontend/help/readhelp.c @@ -60,7 +60,7 @@ topic * hlp_read(fplace *place) { char buf[BSIZE_SP]; - topic *top = alloc(topic); + topic *top = TMALLOC(topic, 1); toplink *topiclink; toplink *tl, *tend = NULL; wordlist *end = NULL; @@ -180,9 +180,9 @@ getsubtoplink(char **ss) s = *ss; - tl = alloc(toplink); + tl = TMALLOC(toplink, 1); if ((tmp =strchr(s, ':')) != NULL) { - tl->place = alloc(fplace); + tl->place = TMALLOC(fplace, 1); tl->place->filename = strncpy(TMALLOC(char, tmp - s + 1), s, (size_t) (tmp - s)); tl->place->filename[tmp - s] = '\0'; diff --git a/src/frontend/inp.c b/src/frontend/inp.c index c07eb91aa..8e5ce9ac3 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -793,7 +793,7 @@ inp_dodeck( ft_curckt->ci_nodes = cp_kwswitch(CT_NODENAMES, NULL); } /* create new circuit structure */ - ft_curckt = ct = alloc(struct circ); + ft_curckt = ct = TMALLOC(struct circ, 1); /*PN FTESTATS*/ ft_curckt->FTEstats = TMALLOC(FTESTATistics, 1); @@ -1631,7 +1631,7 @@ static void inp_savecurrents(struct line *deck, struct line *options, wordlist * /* if we neither have 'save' nor '.save', add '.save all' or if we do not have wl_first, add at least a wordline '*' to allow wl_append_word() */ if (!(*wl) || !havesave) { - *wl = alloc(wordlist); + *wl = TMALLOC(wordlist, 1); (*wl)->wl_next = NULL; (*wl)->wl_prev = NULL; if (havesave) diff --git a/src/frontend/measure.c b/src/frontend/measure.c index 25041593d..667fdbd73 100644 --- a/src/frontend/measure.c +++ b/src/frontend/measure.c @@ -330,7 +330,7 @@ do_measure( } if (!chk_only) { - newcard = alloc(struct line); + newcard = TMALLOC(struct line, 1); newcard->li_line = strdup(out_line); newcard->li_next = NULL; diff --git a/src/frontend/options.c b/src/frontend/options.c index 1110f8268..e0f23b4cd 100644 --- a/src/frontend/options.c +++ b/src/frontend/options.c @@ -51,7 +51,7 @@ cp_enqvar(char *word) return (NULL); if (d->v_length == 1) { - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_next = NULL; vv->va_name = copy(word); vv->va_type = CP_REAL; @@ -60,13 +60,13 @@ cp_enqvar(char *word) else vv->va_real = realpart(d->v_compdata[0]); } else { - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_next = NULL; vv->va_name = copy(word); vv->va_type = CP_LIST; vv->va_vlist = NULL; for (i = d->v_length - 1; i >= 0; i--) { - tv = alloc(struct variable); + tv = TMALLOC(struct variable, 1); tv->va_type = CP_REAL; if (isreal(d)) tv->va_real = d->v_realdata[i]; @@ -89,37 +89,37 @@ cp_enqvar(char *word) if (eq(vv->va_name, word)) return (vv); if (eq(word, "curplotname")) { - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_next = NULL; vv->va_name = word; vv->va_type = CP_STRING; vv->va_string = copy(plot_cur->pl_name); } else if (eq(word, "curplottitle")) { - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_next = NULL; vv->va_name = word; vv->va_type = CP_STRING; vv->va_string = copy(plot_cur->pl_title); } else if (eq(word, "curplotdate")) { - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_next = NULL; vv->va_name = word; vv->va_type = CP_STRING; vv->va_string = copy(plot_cur->pl_date); } else if (eq(word, "curplot")) { - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_next = NULL; vv->va_name = word; vv->va_type = CP_STRING; vv->va_string = copy(plot_cur->pl_typename); } else if (eq(word, "plots")) { - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_next = NULL; vv->va_name = word; vv->va_type = CP_LIST; vv->va_vlist = NULL; for (pl = plot_list; pl; pl = pl->pl_next) { - tv = alloc(struct variable); + tv = TMALLOC(struct variable, 1); tv->va_type = CP_STRING; tv->va_string = copy(pl->pl_typename); tv->va_next = vv->va_vlist; diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index bc2661e03..f2417cb3f 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -161,7 +161,7 @@ beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analNam fprintf(cp_out, "Warning: Interpolated raw file data!\n\n"); } - *runp = run = alloc(struct runDesc); + *runp = run = TMALLOC(struct runDesc, 1); /* First fill in some general information. */ run->analysis = analysisPtr; diff --git a/src/frontend/parse.c b/src/frontend/parse.c index 5c06edc4c..7ecdab336 100644 --- a/src/frontend/parse.c +++ b/src/frontend/parse.c @@ -397,7 +397,7 @@ PP_mksnode(const char *string) struct pnode * alloc_pnode(void) { - struct pnode *pn = alloc(struct pnode); + struct pnode *pn = TMALLOC(struct pnode, 1); pn->pn_use = 0; pn->pn_name = NULL; diff --git a/src/frontend/parser/complete.c b/src/frontend/parser/complete.c index c2211ddb0..59b1252ce 100644 --- a/src/frontend/parser/complete.c +++ b/src/frontend/parser/complete.c @@ -594,7 +594,7 @@ clookup(register char *word, struct ccom **dd, bool pref, bool create) if (!create) { return (NULL); } else { - *dd = place = alloc(struct ccom); + *dd = place = TMALLOC(struct ccom, 1); ZERO(place, struct ccom); buf[0] = *word; buf[1] = '\0'; @@ -617,7 +617,7 @@ clookup(register char *word, struct ccom **dd, bool pref, bool create) if (place->cc_name[ind] < word[ind]) { /* This line doesn't go out that far... */ if (create) { - place->cc_sibling = alloc(struct ccom); + place->cc_sibling = TMALLOC(struct ccom, 1); ZERO(place->cc_sibling, struct ccom); place->cc_sibling->cc_ysibling = place; place->cc_sibling->cc_parent = place->cc_parent; @@ -633,7 +633,7 @@ clookup(register char *word, struct ccom **dd, bool pref, bool create) } else if (place->cc_name[ind] > word[ind]) { if (create) { /* Put this one between place and its pred. */ - tmpc = alloc(struct ccom); + tmpc = TMALLOC(struct ccom, 1); ZERO(tmpc, struct ccom); tmpc->cc_parent = place->cc_parent; tmpc->cc_sibling = place; @@ -663,7 +663,7 @@ clookup(register char *word, struct ccom **dd, bool pref, bool create) if (!place->cc_child) { /* No children, maybe make one and go on. */ if (create) { - tmpc = alloc(struct ccom); + tmpc = TMALLOC(struct ccom, 1); ZERO(tmpc, struct ccom); tmpc->cc_parent = place; place->cc_child = tmpc; diff --git a/src/frontend/parser/unixcom.c b/src/frontend/parser/unixcom.c index b8ba51ba2..6186acae2 100644 --- a/src/frontend/parser/unixcom.c +++ b/src/frontend/parser/unixcom.c @@ -118,7 +118,7 @@ cp_rehash(char *pathlist, bool docc) * executable, but that is too slow * (as if "we" really cared). */ - hh = alloc(struct hashent); + hh = TMALLOC(struct hashent, 1); hh->h_name = copy(entry->d_name); hh->h_path = curpath; i = hash(entry->d_name); diff --git a/src/frontend/rawfile.c b/src/frontend/rawfile.c index d188a4ae7..81e4efc73 100644 --- a/src/frontend/rawfile.c +++ b/src/frontend/rawfile.c @@ -352,7 +352,7 @@ raw_read(char *name) { curpl->pl_commands = wl; } } - curpl = alloc(struct plot); + curpl = TMALLOC(struct plot, 1); curpl->pl_next = plots; plots = curpl; curpl->pl_name = copy(s); diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index efeba5f7c..954c9371d 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -958,7 +958,7 @@ if_setparam(CKTcircuit *ckt, char **name, char *param, struct dvec *val, int do_ static struct variable * parmtovar(IFvalue *pv, IFparm *opt) { - struct variable *vv = alloc(struct variable); + struct variable *vv = TMALLOC(struct variable, 1); struct variable *nv; int i = 0; @@ -983,7 +983,7 @@ parmtovar(IFvalue *pv, IFparm *opt) case IF_REALVEC: vv->va_type = CP_LIST; for (i = 0; i < pv->v.numValue; i++) { - nv = alloc(struct variable); + nv = TMALLOC(struct variable, 1); nv->va_next = vv->va_vlist; vv->va_vlist = nv; nv->va_type = CP_REAL; diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index a352f5d31..6ab147c9b 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -484,7 +484,7 @@ doit(struct line *deck, wordlist *modnames) { { char *s = c->li_line; - sss = alloc(struct subs); + sss = TMALLOC(struct subs, 1); txfree(gettok(&s)); @@ -707,10 +707,10 @@ inp_deckcopy(struct line *deck) { while (deck) { if (nd) { - d->li_next = alloc(struct line); + d->li_next = TMALLOC(struct line, 1); d = d->li_next; } else { - nd = d = alloc(struct line); + nd = d = TMALLOC(struct line, 1); } d->li_linenum = deck->li_linenum; d->li_line = copy(deck->li_line); diff --git a/src/frontend/variable.c b/src/frontend/variable.c index 95798df5f..e3bbbc04b 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -104,7 +104,7 @@ cp_vset(char *varname, enum cp_types type, void *value) } if (!v) { - v = alloc(struct variable); + v = TMALLOC(struct variable, 1); v->va_name = copy(copyvarname); v->va_next = NULL; v_free = TRUE; @@ -282,7 +282,7 @@ cp_setparse(wordlist *wl) wl = wl->wl_next; if ((!wl || (*wl->wl_word != '=')) && !strchr(name, '=')) { - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_name = copy(name); vv->va_type = CP_BOOL; vv->va_bool = TRUE; @@ -346,7 +346,7 @@ cp_setparse(wordlist *wl) if (!--balance) break; } - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_next = NULL; copyval = ss = cp_unquote(wl->wl_word); td = ft_numparse(&ss, FALSE); @@ -374,7 +374,7 @@ cp_setparse(wordlist *wl) return (NULL); } - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_name = copy(name); vv->va_type = CP_LIST; vv->va_vlist = listv; @@ -387,7 +387,7 @@ cp_setparse(wordlist *wl) copyval = ss = cp_unquote(val); td = ft_numparse(&ss, FALSE); - vv = alloc(struct variable); + vv = TMALLOC(struct variable, 1); vv->va_name = copy(name); vv->va_next = vars; vars = vv; @@ -461,7 +461,7 @@ cp_remvar(char *varname) } if (!v) { /* Gotta make up a var struct for cp_usrset()... */ - v = alloc(struct variable); + v = TMALLOC(struct variable, 1); ZERO(v, struct variable); v->va_name = copy(varname); v->va_type = CP_NUM; diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index 7f1f987f0..7ae0d1746 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -732,7 +732,7 @@ vec_copy(struct dvec *v) struct plot * plot_alloc(char *name) { - struct plot *pl = alloc(struct plot), *tp; + struct plot *pl = TMALLOC(struct plot, 1), *tp; char *s; struct ccom *ccom; char buf[BSIZE_SP]; diff --git a/src/include/ngspice/memory.h b/src/include/ngspice/memory.h index 2f9767e8d..658f46552 100644 --- a/src/include/ngspice/memory.h +++ b/src/include/ngspice/memory.h @@ -29,7 +29,6 @@ extern void txfree(void *ptr); #include "ngspice/stringutil.h" /* va: spice3 internally bzero */ -#define alloc(TYPE) TMALLOC(TYPE, 1) #define MALLOC(x) tmalloc((size_t) (x)) #define FREE(x) do { if(x) { txfree(x); (x) = NULL; } } while(0) #define REALLOC(x, y) trealloc(x, (size_t) (y)) diff --git a/src/misc/wlist.c b/src/misc/wlist.c index 28dcf9938..9f028265c 100644 --- a/src/misc/wlist.c +++ b/src/misc/wlist.c @@ -275,7 +275,7 @@ wl_range(wordlist *wl, int low, int up) wordlist * wl_cons(char *word, wordlist *wlist) { - wordlist *w = alloc(wordlist); + wordlist *w = TMALLOC(wordlist, 1); w->wl_next = wlist; w->wl_prev = NULL; w->wl_word = word; @@ -297,7 +297,7 @@ wl_cons(char *word, wordlist *wlist) void wl_append_word(wordlist **first, wordlist **last, char *word) { - wordlist *w = alloc(wordlist); + wordlist *w = TMALLOC(wordlist, 1); w->wl_next = NULL; w->wl_prev = (*last); w->wl_word = word; diff --git a/src/ngsconvert.c b/src/ngsconvert.c index a8e7d2647..d11942ee0 100644 --- a/src/ngsconvert.c +++ b/src/ngsconvert.c @@ -95,7 +95,7 @@ oldread(char *name) perror(name); return (NULL); } - pl = alloc(struct plot); + pl = TMALLOC(struct plot, 1); tfread(buf, 1, 80, fp); buf[80] = '\0'; for (i = (int) strlen(buf) - 1; (i > 1) && (buf[i] == ' '); i--) diff --git a/src/xspice/enh/enhtrans.c b/src/xspice/enh/enhtrans.c index 41b3e4bc3..954ec28a3 100644 --- a/src/xspice/enh/enhtrans.c +++ b/src/xspice/enh/enhtrans.c @@ -115,8 +115,8 @@ struct line * ENHtranslate_poly( #endif /* Create two new line structs and splice into deck */ - l1 = alloc(struct line); - l2 = alloc(struct line); + l1 = TMALLOC(struct line, 1); + l2 = TMALLOC(struct line, 1); l2->li_next = d->li_next; l1->li_next = l2; d->li_next = l1;