aboutsummaryrefslogtreecommitdiff
path: root/b.c
diff options
context:
space:
mode:
authorpfg <pfg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>2017-03-16 21:32:05 +0000
committerArnold D. Robbins <arnold@skeeve.com>2019-07-16 22:12:26 +0300
commit650d868ec4bbb566255702fef37480438163d3ae (patch)
treebeeea30550857f394cd17863dfacc938ed2456c7 /b.c
parent524219409a5b235041353da32d9965ec96be1cd7 (diff)
downloadone-true-awk-650d868ec4bbb566255702fef37480438163d3ae.tar.gz
MFV r315425: one-true-awk: have calloc(3) do the multiplication.
MFC after: 3 days git-svn-id: svn+ssh://svn.freebsd.org/base/head@315426 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Diffstat (limited to 'b.c')
-rw-r--r--b.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/b.c b/b.c
index 421a513..3f6745c 100644
--- a/b.c
+++ b/b.c
@@ -145,7 +145,7 @@ fa *mkdfa(const char *s, int anchor) /* does the real work of making a dfa */
f->accept = poscnt-1; /* penter has computed number of positions in re */
cfoll(f, p1); /* set up follow sets */
freetr(p1);
- if ((f->posns[0] = (int *) calloc(1, *(f->re[0].lfollow)*sizeof(int))) == NULL)
+ if ((f->posns[0] = (int *) calloc(*(f->re[0].lfollow), sizeof(int))) == NULL)
overflo("out of space in makedfa");
if ((f->posns[1] = (int *) calloc(1, sizeof(int))) == NULL)
overflo("out of space in makedfa");
@@ -169,7 +169,7 @@ int makeinit(fa *f, int anchor)
f->reset = 0;
k = *(f->re[0].lfollow);
xfree(f->posns[2]);
- if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL)
+ if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL)
overflo("out of space in makeinit");
for (i=0; i <= k; i++) {
(f->posns[2])[i] = (f->re[0].lfollow)[i];
@@ -369,7 +369,7 @@ void cfoll(fa *f, Node *v) /* enter follow set of each leaf of vertex v into lfo
setvec[i] = 0;
setcnt = 0;
follow(v); /* computes setvec and setcnt */
- if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL)
+ if ((p = (int *) calloc(setcnt+1, sizeof(int))) == NULL)
overflo("out of space building follow set");
f->re[info(v)].lfollow = p;
*p = setcnt;
@@ -543,7 +543,7 @@ int pmatch(fa *f, const char *p0) /* longest match, for sub */
for (i = 2; i <= f->curstat; i++)
xfree(f->posns[i]);
k = *f->posns[0];
- if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL)
+ if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL)
overflo("out of space in pmatch");
for (i = 0; i <= k; i++)
(f->posns[2])[i] = (f->posns[0])[i];
@@ -600,7 +600,7 @@ int nematch(fa *f, const char *p0) /* non-empty match, for sub */
for (i = 2; i <= f->curstat; i++)
xfree(f->posns[i]);
k = *f->posns[0];
- if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL)
+ if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL)
overflo("out of state space");
for (i = 0; i <= k; i++)
(f->posns[2])[i] = (f->posns[0])[i];
@@ -1186,7 +1186,7 @@ int cgoto(fa *f, int s, int c)
for (i = 0; i < NCHARS; i++)
f->gototab[f->curstat][i] = 0;
xfree(f->posns[f->curstat]);
- if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL)
+ if ((p = (int *) calloc(setcnt+1, sizeof(int))) == NULL)
overflo("out of space in cgoto");
f->posns[f->curstat] = p;