api.c
size_t tcmu_memcpy_into_iovec(
	struct iovec *iovec,
	size_t iov_cnt,
	void *src,
	size_t len)
{
	size_t copied = 0;

	while (len && iov_cnt) {
		size_t to_copy = min(iovec->iov_len, len);

		if (to_copy) {
			memcpy(iovec->iov_base, src + copied, to_copy);

			len -= to_copy;
			copied += to_copy;
			iovec->iov_base += to_copy;
			iovec->iov_len -= to_copy;
		}

		iovec++;
		iov_cnt--;
	}

	return copied;
}
/*
 * Copy data into an iovec, and consume the space in the iovec.
 *
 * Will truncate instead of overrunning the iovec.
 */
Copy data into an iovec, and consume the space in the iovec.
Will truncate instead of overrunning the iovec.
Copy data into an iovec and consume the space in the iovec . Will truncate instead of overrunning the iovec .
size_t tcmu_memcpy_into_iovec(
	struct iovec *iovec,
	size_t iov_cnt,
	void *src,
	size_t len)
{
	size_t copied = 0;
	while (len && iov_cnt) {
		size_t to_copy = min(iovec->iov_len, len);
		if (to_copy) {
			memcpy(iovec->iov_base, src + copied, to_copy);
			len -= to_copy;
			copied += to_copy;
			iovec->iov_base += to_copy;
			iovec->iov_len -= to_copy;
		}
		iovec++;
		iov_cnt--;
	}
	return copied;
}
size_t tcmu_memcpy_into_iovec ( struct iovec * iovec , size_t iov_cnt , void * src , size_t len ) { size_t copied = 0 ; while ( len && iov_cnt ) { size_t to_copy = min ( iovec -> iov_len , len ) ; if ( to_copy ) { memcpy ( iovec -> iov_base , src + copied , to_copy ) ; len -= to_copy ; copied += to_copy ; iovec -> iov_base += to_copy ; iovec -> iov_len -= to_copy ; } iovec ++ ; iov_cnt -- ; } return copied ; }
Copy data into an iovec, and consume the space in the iovec.
Copy data into an iovec and consume the space in the iovec .