ash: sprinkle a bit more of zeroed allocations.

This commit is contained in:
Denis Vlasenko 2008-02-21 04:32:08 +00:00
parent 2f518b078b
commit 838ffd5be2

View File

@ -8063,7 +8063,7 @@ mklocal(char *name)
struct var *vp; struct var *vp;
INT_OFF; INT_OFF;
lvp = ckmalloc(sizeof(struct localvar)); lvp = ckzalloc(sizeof(struct localvar));
if (LONE_DASH(name)) { if (LONE_DASH(name)) {
char *p; char *p;
p = ckmalloc(sizeof(optlist)); p = ckmalloc(sizeof(optlist));
@ -8887,7 +8887,7 @@ pushstring(char *s, void *ap)
INT_OFF; INT_OFF;
/*dprintf("*** calling pushstring: %s, %d\n", s, len);*/ /*dprintf("*** calling pushstring: %s, %d\n", s, len);*/
if (parsefile->strpush) { if (parsefile->strpush) {
sp = ckmalloc(sizeof(struct strpush)); sp = ckzmalloc(sizeof(struct strpush));
sp->prev = parsefile->strpush; sp->prev = parsefile->strpush;
parsefile->strpush = sp; parsefile->strpush = sp;
} else } else
@ -9520,7 +9520,7 @@ raise_error_unexpected_syntax(int token)
struct heredoc { struct heredoc {
struct heredoc *next; /* next here document in list */ struct heredoc *next; /* next here document in list */
union node *here; /* redirection node */ union node *here; /* redirection node */
char *eofmark; /* string indicating end of input */ char *eofmark; /* string indicating end of input */
int striptabs; /* if set, strip leading tabs */ int striptabs; /* if set, strip leading tabs */
}; };
@ -9564,7 +9564,7 @@ list(int nlflag)
if (n1 == NULL) { if (n1 == NULL) {
n1 = n2; n1 = n2;
} else { } else {
n3 = stalloc(sizeof(struct nbinary)); n3 = stzalloc(sizeof(struct nbinary));
n3->type = NSEMI; n3->type = NSEMI;
n3->nbinary.ch1 = n1; n3->nbinary.ch1 = n1;
n3->nbinary.ch2 = n2; n3->nbinary.ch2 = n2;
@ -9621,7 +9621,7 @@ andor(void)
} }
checkkwd = CHKNL | CHKKWD | CHKALIAS; checkkwd = CHKNL | CHKKWD | CHKALIAS;
n2 = pipeline(); n2 = pipeline();
n3 = stalloc(sizeof(struct nbinary)); n3 = stzalloc(sizeof(struct nbinary));
n3->type = t; n3->type = t;
n3->nbinary.ch1 = n1; n3->nbinary.ch1 = n1;
n3->nbinary.ch2 = n2; n3->nbinary.ch2 = n2;
@ -9648,12 +9648,12 @@ pipeline(void)
pipenode = stzalloc(sizeof(struct npipe)); pipenode = stzalloc(sizeof(struct npipe));
pipenode->type = NPIPE; pipenode->type = NPIPE;
/*pipenode->npipe.backgnd = 0; - stzalloc did it */ /*pipenode->npipe.backgnd = 0; - stzalloc did it */
lp = stalloc(sizeof(struct nodelist)); lp = stzalloc(sizeof(struct nodelist));
pipenode->npipe.cmdlist = lp; pipenode->npipe.cmdlist = lp;
lp->n = n1; lp->n = n1;
do { do {
prev = lp; prev = lp;
lp = stalloc(sizeof(struct nodelist)); lp = stzalloc(sizeof(struct nodelist));
checkkwd = CHKNL | CHKKWD | CHKALIAS; checkkwd = CHKNL | CHKKWD | CHKALIAS;
lp->n = parse_command(); lp->n = parse_command();
prev->next = lp; prev->next = lp;
@ -9663,7 +9663,7 @@ pipeline(void)
} }
tokpushback = 1; tokpushback = 1;
if (negate) { if (negate) {
n2 = stalloc(sizeof(struct nnot)); n2 = stzalloc(sizeof(struct nnot));
n2->type = NNOT; n2->type = NNOT;
n2->nnot.com = n1; n2->nnot.com = n1;
return n2; return n2;
@ -9747,7 +9747,8 @@ parsefname(void)
if (heredoclist == NULL) if (heredoclist == NULL)
heredoclist = here; heredoclist = here;
else { else {
for (p = heredoclist; p->next; p = p->next); for (p = heredoclist; p->next; p = p->next)
continue;
p->next = here; p->next = here;
} }
} else if (n->type == NTOFD || n->type == NFROMFD) { } else if (n->type == NTOFD || n->type == NFROMFD) {
@ -9828,7 +9829,7 @@ simplecmd(void)
*app = NULL; *app = NULL;
*vpp = NULL; *vpp = NULL;
*rpp = NULL; *rpp = NULL;
n = stalloc(sizeof(struct ncmd)); n = stzalloc(sizeof(struct ncmd));
n->type = NCMD; n->type = NCMD;
n->ncmd.args = args; n->ncmd.args = args;
n->ncmd.assign = vars; n->ncmd.assign = vars;
@ -9854,7 +9855,7 @@ parse_command(void)
raise_error_unexpected_syntax(-1); raise_error_unexpected_syntax(-1);
/* NOTREACHED */ /* NOTREACHED */
case TIF: case TIF:
n1 = stalloc(sizeof(struct nif)); n1 = stzalloc(sizeof(struct nif));
n1->type = NIF; n1->type = NIF;
n1->nif.test = list(0); n1->nif.test = list(0);
if (readtoken() != TTHEN) if (readtoken() != TTHEN)
@ -9862,7 +9863,7 @@ parse_command(void)
n1->nif.ifpart = list(0); n1->nif.ifpart = list(0);
n2 = n1; n2 = n1;
while (readtoken() == TELIF) { while (readtoken() == TELIF) {
n2->nif.elsepart = stalloc(sizeof(struct nif)); n2->nif.elsepart = stzalloc(sizeof(struct nif));
n2 = n2->nif.elsepart; n2 = n2->nif.elsepart;
n2->type = NIF; n2->type = NIF;
n2->nif.test = list(0); n2->nif.test = list(0);
@ -9881,7 +9882,7 @@ parse_command(void)
case TWHILE: case TWHILE:
case TUNTIL: { case TUNTIL: {
int got; int got;
n1 = stalloc(sizeof(struct nbinary)); n1 = stzalloc(sizeof(struct nbinary));
n1->type = (lasttoken == TWHILE) ? NWHILE : NUNTIL; n1->type = (lasttoken == TWHILE) ? NWHILE : NUNTIL;
n1->nbinary.ch1 = list(0); n1->nbinary.ch1 = list(0);
got = readtoken(); got = readtoken();
@ -9897,7 +9898,7 @@ parse_command(void)
case TFOR: case TFOR:
if (readtoken() != TWORD || quoteflag || ! goodname(wordtext)) if (readtoken() != TWORD || quoteflag || ! goodname(wordtext))
raise_error_syntax("Bad for loop variable"); raise_error_syntax("Bad for loop variable");
n1 = stalloc(sizeof(struct nfor)); n1 = stzalloc(sizeof(struct nfor));
n1->type = NFOR; n1->type = NFOR;
n1->nfor.var = wordtext; n1->nfor.var = wordtext;
checkkwd = CHKKWD | CHKALIAS; checkkwd = CHKKWD | CHKALIAS;
@ -9937,7 +9938,7 @@ parse_command(void)
t = TDONE; t = TDONE;
break; break;
case TCASE: case TCASE:
n1 = stalloc(sizeof(struct ncase)); n1 = stzalloc(sizeof(struct ncase));
n1->type = NCASE; n1->type = NCASE;
if (readtoken() != TWORD) if (readtoken() != TWORD)
raise_error_unexpected_syntax(TWORD); raise_error_unexpected_syntax(TWORD);
@ -9958,7 +9959,7 @@ parse_command(void)
while (t != TESAC) { while (t != TESAC) {
if (lasttoken == TLP) if (lasttoken == TLP)
readtoken(); readtoken();
*cpp = cp = stalloc(sizeof(struct nclist)); *cpp = cp = stzalloc(sizeof(struct nclist));
cp->type = NCLIST; cp->type = NCLIST;
app = &cp->nclist.pattern; app = &cp->nclist.pattern;
for (;;) { for (;;) {
@ -10344,13 +10345,13 @@ parseredir: {
/*np->nfile.fd = 0; - stzalloc did it */ /*np->nfile.fd = 0; - stzalloc did it */
} }
np->type = NHERE; np->type = NHERE;
heredoc = stalloc(sizeof(struct heredoc)); heredoc = stzalloc(sizeof(struct heredoc));
heredoc->here = np; heredoc->here = np;
c = pgetc(); c = pgetc();
if (c == '-') { if (c == '-') {
heredoc->striptabs = 1; heredoc->striptabs = 1;
} else { } else {
heredoc->striptabs = 0; /*heredoc->striptabs = 0; - stzalloc did it */
pungetc(); pungetc();
} }
break; break;
@ -10941,7 +10942,7 @@ parseheredoc(void)
union node *n; union node *n;
here = heredoclist; here = heredoclist;
heredoclist = 0; heredoclist = NULL;
while (here) { while (here) {
if (needprompt) { if (needprompt) {