From 0d068a20676144e9fd6796cc77764c420d785394 Mon Sep 17 00:00:00 2001 From: Erik Andersen Date: Tue, 21 Mar 2000 22:32:57 +0000 Subject: * all mallocs now use xmalloc (and so are OOM error safe), and the common error handling saves a few bytes. Thanks to Bob Tinsley for the patch. -Erik --- coreutils/date.c | 2 +- coreutils/dd.c | 6 +----- coreutils/tr.c | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-) (limited to 'coreutils') diff --git a/coreutils/date.c b/coreutils/date.c index b4c3e7153..652db8d74 100644 --- a/coreutils/date.c +++ b/coreutils/date.c @@ -276,7 +276,7 @@ int date_main(int argc, char **argv) } /* Print OUTPUT (after ALL that!) */ - t_buff = malloc(201); + t_buff = xmalloc(201); strftime(t_buff, 200, date_fmt, &tm_time); printf("%s\n", t_buff); diff --git a/coreutils/dd.c b/coreutils/dd.c index 0d5b3e8ab..f40dec712 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -114,11 +114,7 @@ extern int dd_main(int argc, char **argv) argv++; } - buf = malloc(blockSize); - if (buf == NULL) { - fprintf(stderr, "Cannot allocate buffer\n"); - exit(FALSE); - } + buf = xmalloc(blockSize); intotal = 0; outTotal = 0; diff --git a/coreutils/tr.c b/coreutils/tr.c index 8ac09e641..3bfa48080 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c @@ -44,7 +44,7 @@ static char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95"; #endif static const char rcsid[] = - "$Id: tr.c,v 1.1 2000/03/05 08:07:00 erik Exp $"; + "$Id: tr.c,v 1.2 2000/03/21 22:32:57 erik Exp $"; #endif /* not lint */ #endif /* #if 0 */ @@ -433,8 +433,7 @@ STR *s; "unknown class %s", s->str); - if ((cp->set = p = malloc((NCHARS + 1) * sizeof(int))) == NULL) - errx(1, "malloc"); + cp->set = p = xmalloc((NCHARS + 1) * sizeof(int)); bzero(p, (NCHARS + 1) * sizeof(int)); for (cnt = 0, func = cp->func; cnt < NCHARS; ++cnt) -- cgit v1.2.3