ssize_t SVectorIO::Read(const void* buffer, size_t avail) const
{
	const iovec* vec = Vectors();
	ssize_t count = CountVectors();
	size_t total = 0;
	while (--count >= 0 && total < avail) {
		total += vec->iov_len;
		if (total <= avail) memcpy(vec->iov_base, buffer, vec->iov_len);
		else {
			memcpy(vec->iov_base, buffer, vec->iov_len-(total-avail));
			total = avail;
		}
		buffer = static_cast<const uint8_t*>(buffer) + vec->iov_len;
		vec++;
	}
	return total;
}
Пример #2
0
void foo_dummy()
{
  Vectors();
}