summaryrefslogtreecommitdiff
path: root/usr.bin/column
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>2001-07-24 14:13:34 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>2001-07-24 14:13:34 +0000
commitd54a8ce7076144cd0c6c5b308c6f1bdca275904d (patch)
tree632aecd82a2b1b00a0caa31c24304979298b53cf /usr.bin/column
parentf0cb9537214cd3bcb60e3b3f49580ea11153ff10 (diff)
downloadsrc-test2-d54a8ce7076144cd0c6c5b308c6f1bdca275904d.tar.gz
src-test2-d54a8ce7076144cd0c6c5b308c6f1bdca275904d.zip
Remove the misnamed `emalloc' and replace its uses with calloc (along
with error checking) which it effectively was. (malloc+memset)
Notes
Notes: svn path=/head/; revision=80292
Diffstat (limited to 'usr.bin/column')
-rw-r--r--usr.bin/column/column.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/usr.bin/column/column.c b/usr.bin/column/column.c
index e0a50fce11bd..ae732d2cf853 100644
--- a/usr.bin/column/column.c
+++ b/usr.bin/column/column.c
@@ -57,7 +57,6 @@ static const char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95";
#define TAB 8
void c_columnate __P((void));
-void *emalloc __P((int));
void input __P((FILE *));
void maketbl __P((void));
void print __P((void));
@@ -216,9 +215,12 @@ maketbl()
TBL *tbl;
char **cols;
- t = tbl = emalloc(entries * sizeof(TBL));
- cols = emalloc((maxcols = DEFCOLS) * sizeof(char *));
- lens = emalloc(maxcols * sizeof(int));
+ if ((t = tbl = calloc(entries, sizeof(TBL))) == NULL)
+ err(1, (char *)NULL);
+ if ((cols = calloc((maxcols = DEFCOLS), sizeof(char *))) == NULL)
+ err(1, (char *)NULL);
+ if ((lens = calloc(maxcols, sizeof(int))) == NULL)
+ err(1, (char *)NULL);
for (cnt = 0, lp = list; cnt < entries; ++cnt, ++lp, ++t) {
for (coloff = 0, p = *lp; (cols[coloff] = strtok(p, separator));
p = NULL)
@@ -232,8 +234,10 @@ maketbl()
0, DEFCOLS * sizeof(int));
maxcols += DEFCOLS;
}
- t->list = emalloc(coloff * sizeof(char *));
- t->len = emalloc(coloff * sizeof(int));
+ if ((t->list = calloc(coloff, sizeof(char *))) == NULL)
+ err(1, (char *)NULL);
+ if ((t->len = calloc(coloff, sizeof(int))) == NULL)
+ err(1, (char *)NULL);
for (t->cols = coloff; --coloff >= 0;) {
t->list[coloff] = cols[coloff];
t->len[coloff] = strlen(cols[coloff]);
@@ -261,7 +265,9 @@ input(fp)
char *p, buf[MAXLINELEN];
if (!list)
- list = emalloc((maxentry = DEFNUM) * sizeof(char *));
+ if ((list = calloc((maxentry = DEFNUM), sizeof(char *))) ==
+ NULL)
+ err(1, (char *)NULL);
while (fgets(buf, MAXLINELEN, fp)) {
for (p = buf; *p && isspace(*p); ++p);
if (!*p)
@@ -285,18 +291,6 @@ input(fp)
}
}
-void *
-emalloc(size)
- int size;
-{
- char *p;
-
- if (!(p = malloc(size)))
- err(1, NULL);
- memset(p, 0, size);
- return (p);
-}
-
void
usage()
{