[前][次][番号順一覧][スレッド一覧]

ruby-changes:33994

From: normal <ko1@a...>
Date: Sat, 24 May 2014 16:23:04 +0900 (JST)
Subject: [ruby-changes:33994] normal:r46075 (trunk): process.c (proc_getgroups, proc_setgroups): use ALLOCV_N

normal	2014-05-24 16:22:54 +0900 (Sat, 24 May 2014)

  New Revision: 46075

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=46075

  Log:
    process.c (proc_getgroups, proc_setgroups): use ALLOCV_N
    
    * process.c (proc_getgroups, proc_setgroups): use ALLOCV_N
      [Bug #9856]

  Modified files:
    trunk/ChangeLog
    trunk/process.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46074)
+++ ChangeLog	(revision 46075)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat May 24 16:20:59 2014  Eric Wong  <e@8...>
+
+	* process.c (proc_getgroups, proc_setgroups): use ALLOCV_N
+	  [Bug #9856]
+
 Sat May 24 15:49:39 2014  Tanaka Akira  <akr@f...>
 
 	* test/lib/minitest/unit.rb (parallelize_me!): Removed.
Index: process.c
===================================================================
--- process.c	(revision 46074)
+++ process.c	(revision 46075)
@@ -5547,7 +5547,7 @@ maxgroups(void) https://github.com/ruby/ruby/blob/trunk/process.c#L5547
 static VALUE
 proc_getgroups(VALUE obj)
 {
-    VALUE ary;
+    VALUE ary, tmp;
     int i, ngroups;
     rb_gid_t *groups;
 
@@ -5555,7 +5555,7 @@ proc_getgroups(VALUE obj) https://github.com/ruby/ruby/blob/trunk/process.c#L5555
     if (ngroups == -1)
 	rb_sys_fail(0);
 
-    groups = ALLOCA_N(rb_gid_t, ngroups);
+    groups = ALLOCV_N(rb_gid_t, tmp, ngroups);
 
     ngroups = getgroups(ngroups, groups);
     if (ngroups == -1)
@@ -5565,6 +5565,8 @@ proc_getgroups(VALUE obj) https://github.com/ruby/ruby/blob/trunk/process.c#L5565
     for (i = 0; i < ngroups; i++)
 	rb_ary_push(ary, GIDT2NUM(groups[i]));
 
+    ALLOCV_END(tmp);
+
     return ary;
 }
 #else
@@ -5591,6 +5593,7 @@ proc_setgroups(VALUE obj, VALUE ary) https://github.com/ruby/ruby/blob/trunk/process.c#L5593
 {
     int ngroups, i;
     rb_gid_t *groups;
+    VALUE tmp;
     PREPARE_GETGRNAM;
 
     Check_Type(ary, T_ARRAY);
@@ -5599,7 +5602,7 @@ proc_setgroups(VALUE obj, VALUE ary) https://github.com/ruby/ruby/blob/trunk/process.c#L5602
     if (ngroups > maxgroups())
 	rb_raise(rb_eArgError, "too many groups, %d max", maxgroups());
 
-    groups = ALLOCA_N(rb_gid_t, ngroups);
+    groups = ALLOCV_N(rb_gid_t, tmp, ngroups);
 
     for (i = 0; i < ngroups; i++) {
 	VALUE g = RARRAY_AREF(ary, i);
@@ -5611,6 +5614,8 @@ proc_setgroups(VALUE obj, VALUE ary) https://github.com/ruby/ruby/blob/trunk/process.c#L5614
     if (setgroups(ngroups, groups) == -1) /* ngroups <= maxgroups */
 	rb_sys_fail(0);
 
+    ALLOCV_END(tmp);
+
     return proc_getgroups(obj);
 }
 #else

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]