everywhere, use `TMALLOC()' instead of `alloc()'

This commit is contained in:
rlar 2016-03-12 12:20:16 +01:00
parent 7d8e287fa3
commit 4c1c95e20f
24 changed files with 54 additions and 55 deletions

View File

@ -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);

View File

@ -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")) {

View File

@ -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")) {

View File

@ -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;

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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';

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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];

View File

@ -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))

View File

@ -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;

View File

@ -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--)

View File

@ -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;