sf_iova_memset_ex for iov and iovcnt

posix_api
YuQing 2022-02-04 15:37:59 +08:00
parent 5796655ce0
commit fa9e00f3b8
2 changed files with 9 additions and 6 deletions

View File

@ -140,8 +140,8 @@ int sf_iova_next_slice(SFDynamicIOVArray *iova,
return iova_slice(iova, slice_len); return iova_slice(iova, slice_len);
} }
int sf_iova_memset(SFDynamicIOVArray *iova, int c, int sf_iova_memset_ex(struct iovec *iov, const int iovcnt,
const int offset, const int length) int c, const int offset, const int length)
{ {
struct iovec *iob; struct iovec *iob;
struct iovec *end; struct iovec *end;
@ -155,8 +155,8 @@ int sf_iova_memset(SFDynamicIOVArray *iova, int c,
} }
sum_bytes = 0; sum_bytes = 0;
end = iova->iov + iova->cnt; end = iov + iovcnt;
for (iob=iova->iov; iob<end; iob++) { for (iob=iov; iob<end; iob++) {
sum_bytes += iob->iov_len; sum_bytes += iob->iov_len;
if (sum_bytes > offset) { if (sum_bytes > offset) {
break; break;

View File

@ -76,8 +76,11 @@ int sf_iova_first_slice(SFDynamicIOVArray *iova, const int slice_len);
int sf_iova_next_slice(SFDynamicIOVArray *iova, int sf_iova_next_slice(SFDynamicIOVArray *iova,
const int consume_len, const int slice_len); const int consume_len, const int slice_len);
int sf_iova_memset(SFDynamicIOVArray *iova, int c, int sf_iova_memset_ex(struct iovec *iov, const int iovcnt,
const int offset, const int length); int c, const int offset, const int length);
#define sf_iova_memset(iova, c, offset, length) \
sf_iova_memset_ex((iova).iov, (iova).cnt, c, offset, length)
#ifdef __cplusplus #ifdef __cplusplus
} }