Use err instead of errx when malloc fails. "malloc" is not a helpful
error message.
This commit is contained in:
parent
81d858170e
commit
7dd4ac68f1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=99433
@ -94,7 +94,7 @@ main(argc, argv)
|
||||
argc -= optind;
|
||||
|
||||
if ((buf = malloc(BSIZE)) == NULL)
|
||||
errx(1, "malloc");
|
||||
err(1, "malloc");
|
||||
|
||||
add(STDOUT_FILENO, "stdout");
|
||||
|
||||
@ -139,7 +139,7 @@ add(fd, name)
|
||||
LIST *p;
|
||||
|
||||
if ((p = malloc(sizeof(LIST))) == NULL)
|
||||
errx(1, "malloc");
|
||||
err(1, "malloc");
|
||||
p->fd = fd;
|
||||
p->name = name;
|
||||
p->next = head;
|
||||
|
@ -202,7 +202,7 @@ genclass(s)
|
||||
errx(1, "unknown class %s", s->str);
|
||||
|
||||
if ((cp->set = p = malloc((NCHARS + 1) * sizeof(int))) == NULL)
|
||||
errx(1, "malloc");
|
||||
err(1, "malloc");
|
||||
bzero(p, (NCHARS + 1) * sizeof(int));
|
||||
for (cnt = 0, func = cp->func; cnt < NCHARS; ++cnt)
|
||||
if ((func)(cnt))
|
||||
|
@ -136,10 +136,12 @@ main (argc, argv)
|
||||
prevline = malloc(MAXLINELEN);
|
||||
thisline = malloc(MAXLINELEN);
|
||||
if (prevline == NULL || thisline == NULL)
|
||||
errx(1, "malloc");
|
||||
err(1, "malloc");
|
||||
|
||||
if (getline(prevline, MAXLINELEN, ifp) == NULL)
|
||||
exit(0);
|
||||
if (!cflag && uflag && dflag)
|
||||
show(ofp, prevline);
|
||||
|
||||
while (getline(thisline, MAXLINELEN, ifp)) {
|
||||
/* If requested get the chosen fields + character offsets. */
|
||||
@ -158,15 +160,19 @@ main (argc, argv)
|
||||
comp = strcoll(t1, t2);
|
||||
|
||||
if (comp) {
|
||||
show(ofp, prevline);
|
||||
if (cflag || !dflag || !uflag)
|
||||
show(ofp, prevline);
|
||||
t1 = prevline;
|
||||
prevline = thisline;
|
||||
if (!cflag && uflag && dflag)
|
||||
show(ofp, prevline);
|
||||
thisline = t1;
|
||||
repeats = 0;
|
||||
} else
|
||||
++repeats;
|
||||
}
|
||||
show(ofp, prevline);
|
||||
if (cflag || !dflag || !uflag)
|
||||
show(ofp, prevline);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -253,7 +259,7 @@ obsolete(argv)
|
||||
*/
|
||||
len = strlen(ap);
|
||||
if ((start = p = malloc(len + 3)) == NULL)
|
||||
errx(1, "malloc");
|
||||
err(1, "malloc");
|
||||
*p++ = '-';
|
||||
*p++ = ap[0] == '+' ? 's' : 'f';
|
||||
(void)strcpy(p, ap + 1);
|
||||
|
Loading…
Reference in New Issue
Block a user