Module Name: src
Committed By: christos
Date: Mon Nov 19 19:41:31 UTC 2012
Modified Files:
src/bin/cat: cat.c
Log Message:
only allocate if it would not fit in our buffer.
To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/bin/cat/cat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.51 src/bin/cat/cat.c:1.52
--- src/bin/cat/cat.c:1.51 Mon Nov 19 14:34:03 2012
+++ src/bin/cat/cat.c Mon Nov 19 14:41:31 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.51 2012/11/19 19:34:03 christos Exp $ */
+/* $NetBSD: cat.c,v 1.52 2012/11/19 19:41:31 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
#else
-__RCSID("$NetBSD: cat.c,v 1.51 2012/11/19 19:34:03 christos Exp $");
+__RCSID("$NetBSD: cat.c,v 1.52 2012/11/19 19:41:31 christos Exp $");
#endif
#endif /* not lint */
@@ -302,11 +302,12 @@ raw_cat(int rfd)
(size_t)sbuf.st_blksize > sizeof(fb_buf))
bsize = sbuf.st_blksize;
}
- if (bsize != 0)
+ if (bsize > sizeof(fb_buf)) {
buf = malloc(bsize);
- if (buf == NULL) {
- if (bsize != 0)
+ if (buf == NULL)
warnx("malloc, using %zu buffer", bsize);
+ }
+ if (buf == NULL) {
bsize = sizeof(fb_buf);
buf = fb_buf;
}