about summary refs log tree commit homepage
path: root/ext/io_splice
diff options
context:
space:
mode:
Diffstat (limited to 'ext/io_splice')
-rw-r--r--ext/io_splice/io_splice_ext.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/ext/io_splice/io_splice_ext.c b/ext/io_splice/io_splice_ext.c
index 1c938c3..9a838df 100644
--- a/ext/io_splice/io_splice_ext.c
+++ b/ext/io_splice/io_splice_ext.c
@@ -108,9 +108,6 @@ rb_thread_blocking_region(
 #ifndef RSTRING_LEN
 #  define RSTRING_LEN(s) (RSTRING(s)->len)
 #endif
-#ifndef RARRAY_PTR
-#  define RARRAY_PTR(s) (RARRAY(s)->ptr)
-#endif
 #ifndef RARRAY_LEN
 #  define RARRAY_LEN(s) (RARRAY(s)->len)
 #endif
@@ -416,20 +413,18 @@ static VALUE nogvl_vmsplice(void *ptr)
 /* this can't be a function since we use alloca() */
 #define ARY2IOVEC(iov,iovcnt,expect,ary) \
 do { \
-        VALUE *cur; \
         struct iovec *tmp; \
-        long n; \
-        cur = RARRAY_PTR(ary); \
-        n = RARRAY_LEN(ary); \
-        if (n > IOV_MAX) \
+        unsigned long i; \
+        iovcnt = (unsigned long)RARRAY_LEN(ary); \
+        if (iovcnt > IOV_MAX) \
                 rb_raise(rb_eArgError, "array is larger than IOV_MAX"); \
-        iov = tmp = alloca(sizeof(struct iovec) * n); \
+        iov = tmp = alloca(sizeof(struct iovec) * iovcnt); \
         expect = 0; \
-        iovcnt = n; \
-        for (; --n >= 0; tmp++, cur++) { \
-                Check_Type(*cur, T_STRING); \
-                tmp->iov_base = RSTRING_PTR(*cur); \
-                tmp->iov_len = RSTRING_LEN(*cur); \
+        for (i = 0; i < iovcnt; tmp++, i++) { \
+                VALUE cur = rb_ary_entry(ary, (long)i); \
+                Check_Type(cur, T_STRING); \
+                tmp->iov_base = RSTRING_PTR(cur); \
+                tmp->iov_len = RSTRING_LEN(cur); \
                 expect += tmp->iov_len; \
         } \
 } while (0)