diff options
Diffstat (limited to 'src/libstddjb/siovec_seek.c')
-rw-r--r-- | src/libstddjb/siovec_seek.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/libstddjb/siovec_seek.c b/src/libstddjb/siovec_seek.c index 34a8918..f03b20a 100644 --- a/src/libstddjb/siovec_seek.c +++ b/src/libstddjb/siovec_seek.c @@ -1,24 +1,26 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/bytestr.h> #include <skalibs/siovec.h> -unsigned int siovec_seek (siovec_t *v, unsigned int n, unsigned int len) +size_t siovec_seek (struct iovec *v, unsigned int n, size_t len) { - unsigned int w = 0 ; + size_t w = 0 ; register unsigned int i = 0 ; for (; i < n ; i++) { - if (len < v[i].len) break ; - w += v[i].len ; - len -= v[i].len ; - v[i].s = 0 ; - v[i].len = 0 ; + if (len < v[i].iov_len) break ; + w += v[i].iov_len ; + len -= v[i].iov_len ; + v[i].iov_base = 0 ; + v[i].iov_len = 0 ; } if (i < n) { - v[i].s += len ; - v[i].len -= len ; + v[i].iov_base = (char *)v[i].iov_base + len ; + v[i].iov_len -= len ; w += len ; } return w ; |