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

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

		if (to_copy) {
			memcpy(dest + copied, iovec->iov_base, 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 from an iovec, and consume the space in the iovec.
 */
Copy data from an iovec, and consume the space in the iovec.
Copy data from an iovec and consume the space in the iovec .
size_t tcmu_memcpy_from_iovec(
	void *dest,
	size_t len,
	struct iovec *iovec,
	size_t iov_cnt)
{
	size_t copied = 0;
	while (len && iov_cnt) {
		size_t to_copy = min(iovec->iov_len, len);
		if (to_copy) {
			memcpy(dest + copied, iovec->iov_base, 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_from_iovec ( void * dest , size_t len , struct iovec * iovec , size_t iov_cnt ) { size_t copied = 0 ; while ( len && iov_cnt ) { size_t to_copy = min ( iovec -> iov_len , len ) ; if ( to_copy ) { memcpy ( dest + copied , iovec -> iov_base , 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 from an iovec, and consume the space in the iovec.
Copy data from an iovec and consume the space in the iovec .