[Midnightbsd-cvs] src [11168] trunk/contrib/one-true-awk/b.c: fix some pointer stuff

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Wed Jun 27 18:46:22 EDT 2018


Revision: 11168
          http://svnweb.midnightbsd.org/src/?rev=11168
Author:   laffer1
Date:     2018-06-27 18:46:21 -0400 (Wed, 27 Jun 2018)
Log Message:
-----------
fix some pointer stuff

Modified Paths:
--------------
    trunk/contrib/one-true-awk/b.c

Modified: trunk/contrib/one-true-awk/b.c
===================================================================
--- trunk/contrib/one-true-awk/b.c	2018-06-27 22:44:27 UTC (rev 11167)
+++ trunk/contrib/one-true-awk/b.c	2018-06-27 22:46:21 UTC (rev 11168)
@@ -1,4 +1,3 @@
-/* $MidnightBSD$ */
 /****************************************************************
 Copyright (C) Lucent Technologies 1997
 All Rights Reserved
@@ -26,6 +25,7 @@
 /* lasciate ogne speranza, voi ch'intrate. */
 
 #include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/contrib/one-true-awk/b.c 315582 2017-03-19 20:04:57Z pfg $");
 
 #define	DEBUG
 
@@ -140,7 +140,7 @@
 	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 @@
 	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 @@
 			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 @@
 			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 @@
 			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 @@
 	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;



More information about the Midnightbsd-cvs mailing list