/* zmapfd - read contents of file descriptor into a newly-allocated buffer */
-/* Copyright (C) 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2006-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
extern int errno;
#endif
-extern ssize_t zread __P((int, char *, size_t));
+#ifndef ZBUFSIZ
+# define ZBUFSIZ 4096
+#endif
+
+extern ssize_t zread PARAMS((int, char *, size_t));
/* Dump contents of file descriptor FD to *OSTR. FN is the filename for
error messages (not used right now). */
{
ssize_t nr;
int rval;
- char lbuf[128];
+ char lbuf[ZBUFSIZ];
char *result;
int rsize, rind;
rval = 0;
- result = (char *)xmalloc (rsize = 64);
+ result = (char *)xmalloc (rsize = ZBUFSIZ);
rind = 0;
while (1)
return -1;
}
- RESIZE_MALLOCED_BUFFER (result, rind, nr, rsize, 128);
+ RESIZE_MALLOCED_BUFFER (result, rind, nr, rsize, ZBUFSIZ);
memcpy (result+rind, lbuf, nr);
rind += nr;
}