about summary refs log tree commit homepage
path: root/ext
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-28 00:21:28 +0000
committerEric Wong <normalperson@yhbt.net>2011-02-28 00:21:28 +0000
commit38273a2a81db814eacd2257665eac2fe3ecd3b94 (patch)
treea7dfc4f44e4c7ca703ecc6115bf5e8112670251e /ext
parent813c5300294046f9ae0f4bac8449a4734ddd7fd9 (diff)
downloadruby_io_splice-38273a2a81db814eacd2257665eac2fe3ecd3b94.tar.gz
For consistency with all of our other methods.
Diffstat (limited to 'ext')
-rw-r--r--ext/io_splice/io_splice_ext.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/io_splice/io_splice_ext.c b/ext/io_splice/io_splice_ext.c
index c97435e..14f7042 100644
--- a/ext/io_splice/io_splice_ext.c
+++ b/ext/io_splice/io_splice_ext.c
@@ -361,11 +361,14 @@ static void advance_vmsplice_args(struct vmsplice_args *a, long n)
  * See manpage for full documentation:
  * http://kernel.org/doc/man-pages/online/pages/man2/vmsplice.2.html
  */
-static VALUE my_vmsplice(VALUE self, VALUE fd, VALUE data, VALUE flags)
+static VALUE my_vmsplice(int argc, VALUE * argv, VALUE self)
 {
         long rv = 0;
         ssize_t left;
         struct vmsplice_args a;
+        VALUE fd, data, flags;
+
+        rb_scan_args(argc, argv, "21", &fd, &data, &flags);
 
         switch (TYPE(data)) {
         case T_STRING: {
@@ -386,7 +389,7 @@ static VALUE my_vmsplice(VALUE self, VALUE fd, VALUE data, VALUE flags)
                          rb_obj_classname(data));
         }
         a.fd = my_fileno(fd);
-        a.flags = NUM2UINT(flags);
+        a.flags = NIL_P(flags) ? 0 : NUM2UINT(flags);
 
         for (;;) {
                 long n = (long)nb_io_run(nogvl_vmsplice, &a, a.flags);
@@ -494,7 +497,7 @@ void Init_io_splice_ext(void)
         rb_define_singleton_method(rb_cIO, "trysplice", trysplice, -1);
         rb_define_singleton_method(rb_cIO, "tee", my_tee, -1);
         rb_define_singleton_method(rb_cIO, "trytee", trytee, -1);
-        rb_define_singleton_method(rb_cIO, "vmsplice", my_vmsplice, 3);
+        rb_define_singleton_method(rb_cIO, "vmsplice", my_vmsplice, -1);
 
         /*
          * Attempt to move pages instead of copying.  This is only a hint