siovec_gather.c (406B)
1 /* ISC license. */ 2 3 #include <sys/uio.h> 4 #include <string.h> 5 #include <skalibs/siovec.h> 6 7 size_t siovec_gather (struct iovec const *v, unsigned int n, char *s, size_t max) 8 { 9 size_t w = 0 ; 10 unsigned int i = 0 ; 11 for (; i < n && w < max ; i++) 12 { 13 size_t len = v[i].iov_len ; 14 if (len > max - w) len = max - w ; 15 if (len) memmove(s + w, v[i].iov_base, len) ; 16 w += len ; 17 } 18 return w ; 19 }