Mail Archives: djgpp-workers/2003/01/23/01:36:57
On Wed, 22 Jan 2003, Richard Dawe wrote:
> The calls allocate a buffer big enough to store all the data
> for the I/O vector, so that a single read or write call can be used.
> This seemed like the simplest and most robust way of doing it, since
> there are no readv or writev system calls.
This design worries me a bit. The buffer you allocate can be quite
large, in which case we are talking some major heap exercising. The
function could even unjustly fail (for lack of enough memory) in some
borderline cases, like if the file is much smaller than what you tell
the function about the buffers' length.
What exactly are the problems in doing this straightforwardly, i.e. read
into the buffers directly one by one? What am I missing?
> + /* Read in the data. */
> + ret = read(fd, buf, maxbytes);
Can't you use _read instead? Is readv supposed to handle text files and
do CRLF->NL conversions?
The same holds for _write in writev.
> + @subheading Syntax
> +
> + @example
> + #include <sys/uio.h>
> +
> + ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
> + @end example
[...]
> + @code{struct iovec} is defined as follows:
Since we are about to add index entries to the manual, how about having
@findex at the beginning of the node and @tindex for `struct iovec'?
> + Otherwise, a value of -1 is returned and @var{errno} is set appropriately.
`errno' is the actual name of a variable, it does not stand for something
else. So it should be in @code, not in @var.
And please don't forget an entry in wc204.txi.
Last but not least, thanks for working on this.
- Raw text -