Loading...
--- Libc/Libc-1725.40.4/stdio/FreeBSD/fvwrite.c
+++ Libc/Libc-825.26/stdio/FreeBSD/fvwrite.c
@@ -36,7 +36,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/stdio/fvwrite.c,v 1.19 2009/11/25 04:21:42 wollman Exp $");
-#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -50,7 +49,9 @@
* to the three different kinds of output buffering is handled here.
*/
int
-__sfvwrite(FILE *fp, struct __suio *uio)
+__sfvwrite(fp, uio)
+ FILE *fp;
+ struct __suio *uio;
{
size_t len;
char *p;
@@ -81,12 +82,11 @@
}
if (fp->_flags & __SNBF) {
/*
- * Unbuffered: write up to INT_MAX bytes at a time, to not truncate
- * the value of len if it is greater than 2^31 bytes.
+ * Unbuffered: write up to BUFSIZ bytes at a time.
*/
do {
GETIOV(;);
- w = _swrite(fp, p, MIN(len, INT_MAX));
+ w = _swrite(fp, p, MIN(len, BUFSIZ));
if (w <= 0)
goto err;
p += w;
@@ -96,8 +96,7 @@
/*
* Fully buffered: fill partially full buffer, if any,
* and then flush. If there is no partial buffer, write
- * entire payload directly (without copying) up to a multiple of
- * the buffer size.
+ * one _bf._size byte chunk directly (without copying).
*
* String output is a special case: write as many bytes
* as fit, but pretend we wrote everything. This makes
@@ -141,12 +140,7 @@
if (__fflush(fp))
goto err;
} else if (len >= (w = fp->_bf._size)) {
- /* write directly up to INT_MAX or greatest multiple of buffer
- * size (whatever is smaller), keeping in the memory buffer the
- * remaining part of payload that is smaller than buffer size.
- */
- if (w != 0)
- w = MIN(w * (len / w), INT_MAX);
+ /* write directly */
w = _swrite(fp, p, w);
if (w <= 0)
goto err;