Author: pfg
Date: Sun Mar 19 20:04:23 2017
New Revision: 315581
URL: https://svnweb.freebsd.org/changeset/base/315581

Log:
  MFC r315426, MFV r315425:
  one-true-awk: have calloc(3) do the multiplication.

Modified:
  stable/11/contrib/one-true-awk/b.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/one-true-awk/b.c
==============================================================================
--- stable/11/contrib/one-true-awk/b.c  Sun Mar 19 19:52:47 2017        
(r315580)
+++ stable/11/contrib/one-true-awk/b.c  Sun Mar 19 20:04:23 2017        
(r315581)
@@ -140,7 +140,7 @@ fa *mkdfa(const char *s, int anchor)        /* 
        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");
@@ -160,7 +160,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];
@@ -375,7 +375,7 @@ void cfoll(fa *f, Node *v)  /* enter foll
                        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;
@@ -549,7 +549,7 @@ int pmatch(fa *f, const char *p0)   /* lon
                        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];
@@ -606,7 +606,7 @@ int nematch(fa *f, const char *p0)  /* no
                        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];
@@ -943,7 +943,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;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to