According to Pointer arithmetic for void pointer in C, arithmetic with void pointers is not allowed. Yet, the iovec
structure looks like so:
struct iovec {
void *iov_base;
size_t iov_len;
};
This is defined in the POSIX standard, and the iov_len
field is described as the somewhat vague "The size of the memory pointed to by iov_base". Since iovec
is just a data structure, I wondered if the functions that accept it as input parameters define how they use the iov_len
field, but both readv
and writev
desribe it, again vaguely, as "the length of an area of memory."
For some functions, the meaning of the iov_len
field does seem to be explicitly defined. For example, the recvmsg
specification says the "iov_len field gives [the storage area's] size in bytes". Additionally, recv
, which accepts a void pointer and length, properly defines the length parameter as the length of the buffer in bytes.
My question: Is the meaning of the iov_len
field well-defined in these cases where it's defined as the length of a buffer?