summaryrefslogtreecommitdiff
path: root/src/libstddjb/siovec_deal.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-02-17 22:30:53 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-02-17 22:30:53 +0000
commitfdffefb8032922ce7ffe4c00816072a8ff2148fc (patch)
treebc7313151a429c45d8bab8ad8b9dd32f4e51335f /src/libstddjb/siovec_deal.c
parenta896ca2a8c617e5e00ffd5fc9e69331ad754e5b3 (diff)
downloadskalibs-fdffefb8032922ce7ffe4c00816072a8ff2148fc.tar.xz
More types changes
New disize Add size_t to the autotypes list Delete redundant and replace-libc files dev_t/ino_t pass Big size_t pass More things missing, still not operational yet
Diffstat (limited to 'src/libstddjb/siovec_deal.c')
-rw-r--r--src/libstddjb/siovec_deal.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/libstddjb/siovec_deal.c b/src/libstddjb/siovec_deal.c
index fffea92..3f802b9 100644
--- a/src/libstddjb/siovec_deal.c
+++ b/src/libstddjb/siovec_deal.c
@@ -1,24 +1,26 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <string.h>
#include <skalibs/siovec.h>
-unsigned int siovec_deal (siovec_t const *vj, unsigned int nj, siovec_t const *vi, unsigned int ni)
+size_t siovec_deal (struct iovec const *vj, unsigned int nj, struct iovec const *vi, unsigned int ni)
{
- unsigned int w = 0 ;
+ size_t w = 0 ;
+ size_t wi = 0 ;
+ size_t wj = 0 ;
unsigned int i = 0 ;
unsigned int j = 0 ;
- unsigned int wi = 0 ;
- unsigned int wj = 0 ;
while (i < ni && j < nj)
{
- register unsigned int tor = vi[i].len - wi ;
- register unsigned int tow = vj[j].len - wj ;
- register unsigned int len = tor < tow ? tor : tow ;
- byte_copy(vj[j].s + wj, len, vi[i].s + wi) ;
+ size_t tor = vi[i].iov_len - wi ;
+ size_t tow = vj[j].iov_len - wj ;
+ size_t len = tor < tow ? tor : tow ;
+ memmove((char *)vj[j].iov_base + wj, (char const *)vi[i].iov_base + wi, len) ;
wi += len ; wj += len ; w += len ;
- if (wi >= vi[i].len) { wi = 0 ; i++ ; }
- if (wj >= vj[j].len) { wj = 0 ; j++ ; }
+ if (wi >= vi[i].iov_len) { wi = 0 ; i++ ; }
+ if (wj >= vj[j].iov_len) { wj = 0 ; j++ ; }
}
return w ;
}