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

ruby-changes:40373

From: nobu <ko1@a...>
Date: Thu, 5 Nov 2015 10:09:47 +0900 (JST)
Subject: [ruby-changes:40373] nobu:r52453 (trunk): ext: use RARRAY_AREF

nobu	2015-11-05 10:09:17 +0900 (Thu, 05 Nov 2015)

  New Revision: 52453

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

  Log:
    ext: use RARRAY_AREF
    
    * ext/**/*.c: prefer RARRAY_AREF to indexing RARRAY_CONST_PTR.
      pointed out by hanmac.
      https://github.com/ruby/ruby/commit/3553a86#commitcomment-14187670

  Modified files:
    trunk/ChangeLog
    trunk/ext/bigdecimal/bigdecimal.c
    trunk/ext/date/date_core.c
    trunk/ext/dbm/dbm.c
    trunk/ext/fiddle/closure.c
    trunk/ext/fiddle/function.c
    trunk/ext/gdbm/gdbm.c
    trunk/ext/openssl/ossl_ocsp.c
    trunk/ext/openssl/ossl_ssl.c
    trunk/ext/openssl/ossl_x509cert.c
    trunk/ext/openssl/ossl_x509crl.c
    trunk/ext/openssl/ossl_x509req.c
    trunk/ext/openssl/ossl_x509revoked.c
    trunk/ext/psych/psych_emitter.c
    trunk/ext/readline/readline.c
    trunk/ext/sdbm/init.c
    trunk/ext/socket/ancdata.c
    trunk/ext/socket/socket.c
    trunk/ext/tk/tcltklib.c
    trunk/ext/tk/tkutil/tkutil.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52452)
+++ ChangeLog	(revision 52453)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Nov  5 10:09:12 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/**/*.c: prefer RARRAY_AREF to indexing RARRAY_CONST_PTR.
+	  pointed out by hanmac.
+	  https://github.com/ruby/ruby/commit/3553a86#commitcomment-14187670
+
 Wed Nov  4 17:33:24 2015  SHIBATA Hiroshi  <hsbt@r...>
 
 	* lib/debug.rb: Add documentation for #thread_list_all.
Index: ext/bigdecimal/bigdecimal.c
===================================================================
--- ext/bigdecimal/bigdecimal.c	(revision 52452)
+++ ext/bigdecimal/bigdecimal.c	(revision 52453)
@@ -699,7 +699,7 @@ BigDecimal_to_i(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L699
     }
     else {
 	VALUE a = BigDecimal_split(self);
-	VALUE digits = RARRAY_CONST_PTR(a)[1];
+	VALUE digits = RARRAY_AREF(a, 1);
 	VALUE numerator = rb_funcall(digits, rb_intern("to_i"), 0);
 	VALUE ret;
 	ssize_t dpower = e - (ssize_t)RSTRING_LEN(digits);
@@ -788,7 +788,7 @@ BigDecimal_to_r(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L788
     sign = VpGetSign(p);
     power = VpExponent10(p);
     a = BigDecimal_split(self);
-    digits = RARRAY_CONST_PTR(a)[1];
+    digits = RARRAY_AREF(a, 1);
     denomi_power = power - RSTRING_LEN(digits);
     numerator = rb_funcall(digits, rb_intern("to_i"), 0);
 
Index: ext/sdbm/init.c
===================================================================
--- ext/sdbm/init.c	(revision 52452)
+++ ext/sdbm/init.c	(revision 52453)
@@ -530,7 +530,7 @@ fsdbm_delete_if(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ext/sdbm/init.c#L530
     }
 
     for (i = 0; i < RARRAY_LEN(ary); i++) {
-	keystr = RARRAY_CONST_PTR(ary)[i];
+	keystr = RARRAY_AREF(ary, i);
 	ExportStringValue(keystr);
 	key.dptr = RSTRING_PTR(keystr);
 	key.dsize = RSTRING_LENINT(keystr);
Index: ext/date/date_core.c
===================================================================
--- ext/date/date_core.c	(revision 52452)
+++ ext/date/date_core.c	(revision 52453)
@@ -3826,14 +3826,14 @@ rt_complete_frags(VALUE klass, VALUE has https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L3826
 	for (i = 0; i < RARRAY_LEN(tab); i++) {
 	    VALUE x, a;
 
-	    x = RARRAY_CONST_PTR(tab)[i];
-	    a = RARRAY_CONST_PTR(x)[1];
+	    x = RARRAY_AREF(tab, i);
+	    a = RARRAY_AREF(x, 1);
 
 	    {
 		long j, n = 0;
 
 		for (j = 0; j < RARRAY_LEN(a); j++)
-		    if (!NIL_P(ref_hash0(RARRAY_CONST_PTR(a)[j])))
+		    if (!NIL_P(ref_hash0(RARRAY_AREF(a, j))))
 			n++;
 		if (n > eno) {
 		    eno = n;
@@ -3845,8 +3845,8 @@ rt_complete_frags(VALUE klass, VALUE has https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L3845
 	    g = 0;
 	else {
 	    g = 1;
-	    k = RARRAY_CONST_PTR(RARRAY_CONST_PTR(tab)[idx])[0];
-	    a = RARRAY_CONST_PTR(RARRAY_CONST_PTR(tab)[idx])[1];
+	    k = RARRAY_AREF(RARRAY_AREF(tab, idx), 0);
+	    a = RARRAY_AREF(RARRAY_AREF(tab, idx), 1);
 	    e =	eno;
 	}
     }
@@ -3867,7 +3867,7 @@ rt_complete_frags(VALUE klass, VALUE has https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L3867
 	    long i;
 
 	    for (i = 0; i < RARRAY_LEN(a); i++) {
-		VALUE e = RARRAY_CONST_PTR(a)[i];
+		VALUE e = RARRAY_AREF(a, i);
 
 		if (!NIL_P(ref_hash0(e)))
 		    break;
@@ -3884,7 +3884,7 @@ rt_complete_frags(VALUE klass, VALUE has https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L3884
 	    long i;
 
 	    for (i = 0; i < RARRAY_LEN(a); i++) {
-		VALUE e = RARRAY_CONST_PTR(a)[i];
+		VALUE e = RARRAY_AREF(a, i);
 
 		if (!NIL_P(ref_hash0(e)))
 		    break;
@@ -3908,7 +3908,7 @@ rt_complete_frags(VALUE klass, VALUE has https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L3908
 	    long i;
 
 	    for (i = 0; i < RARRAY_LEN(a); i++) {
-		VALUE e = RARRAY_CONST_PTR(a)[i];
+		VALUE e = RARRAY_AREF(a, i);
 
 		if (!NIL_P(ref_hash0(e)))
 		    break;
@@ -3925,7 +3925,7 @@ rt_complete_frags(VALUE klass, VALUE has https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L3925
 	    long i;
 
 	    for (i = 0; i < RARRAY_LEN(a); i++) {
-		VALUE e = RARRAY_CONST_PTR(a)[i];
+		VALUE e = RARRAY_AREF(a, i);
 
 		if (!NIL_P(ref_hash0(e)))
 		    break;
@@ -7085,16 +7085,16 @@ d_lite_marshal_load(VALUE self, VALUE a) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7085
 
 
 	    if  (RARRAY_LEN(a) == 2) {
-		ajd = f_sub(RARRAY_CONST_PTR(a)[0], half_days_in_day);
+		ajd = f_sub(RARRAY_AREF(a, 0), half_days_in_day);
 		of = INT2FIX(0);
-		sg = RARRAY_CONST_PTR(a)[1];
+		sg = RARRAY_AREF(a, 1);
 		if (!k_numeric_p(sg))
 		    sg = DBL2NUM(RTEST(sg) ? GREGORIAN : JULIAN);
 	    }
 	    else {
-		ajd = RARRAY_CONST_PTR(a)[0];
-		of = RARRAY_CONST_PTR(a)[1];
-		sg = RARRAY_CONST_PTR(a)[2];
+		ajd = RARRAY_AREF(a, 0);
+		of = RARRAY_AREF(a, 1);
+		sg = RARRAY_AREF(a, 2);
 	    }
 
 	    old_to_new(ajd, of, sg,
@@ -7119,12 +7119,12 @@ d_lite_marshal_load(VALUE self, VALUE a) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7119
 	    int jd, df, of;
 	    double sg;
 
-	    nth = RARRAY_CONST_PTR(a)[0];
-	    jd = NUM2INT(RARRAY_CONST_PTR(a)[1]);
-	    df = NUM2INT(RARRAY_CONST_PTR(a)[2]);
-	    sf = RARRAY_CONST_PTR(a)[3];
-	    of = NUM2INT(RARRAY_CONST_PTR(a)[4]);
-	    sg = NUM2DBL(RARRAY_CONST_PTR(a)[5]);
+	    nth = RARRAY_AREF(a, 0);
+	    jd = NUM2INT(RARRAY_AREF(a, 1));
+	    df = NUM2INT(RARRAY_AREF(a, 2));
+	    sf = RARRAY_AREF(a, 3);
+	    of = NUM2INT(RARRAY_AREF(a, 4));
+	    sg = NUM2DBL(RARRAY_AREF(a, 5));
 	    if (!df && f_zero_p(sf) && !of) {
 		set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD);
 	    } else {
Index: ext/tk/tcltklib.c
===================================================================
--- ext/tk/tcltklib.c	(revision 52452)
+++ ext/tk/tcltklib.c	(revision 52453)
@@ -1892,15 +1892,15 @@ set_max_block_time(self, time) https://github.com/ruby/ruby/blob/trunk/ext/tk/tcltklib.c#L1892
     case T_BIGNUM:
         /* time is micro-second value */
         divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000));
-        tcl_time.sec  = NUM2LONG(RARRAY_CONST_PTR(divmod)[0]);
-        tcl_time.usec = NUM2LONG(RARRAY_CONST_PTR(divmod)[1]);
+        tcl_time.sec  = NUM2LONG(RARRAY_AREF(divmod, 0));
+        tcl_time.usec = NUM2LONG(RARRAY_AREF(divmod, 1));
         break;
 
     case T_FLOAT:
         /* time is second value */
         divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1));
-        tcl_time.sec  = NUM2LONG(RARRAY_CONST_PTR(divmod)[0]);
-        tcl_time.usec = (long)(NUM2DBL(RARRAY_CONST_PTR(divmod)[1]) * 1000000);
+        tcl_time.sec  = NUM2LONG(RARRAY_AREF(divmod, 0));
+        tcl_time.usec = (long)(NUM2DBL(RARRAY_AREF(divmod, 1)) * 1000000);
 
     default:
         {
@@ -7213,7 +7213,7 @@ tk_funcall(func, argc, argv, obj) https://github.com/ruby/ruby/blob/trunk/ext/tk/tcltklib.c#L7213
     DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
 
     /* get result & free allocated memory */
-    ret = RARRAY_CONST_PTR(result)[0];
+    ret = RARRAY_AREF(result, 0);
 #if 0 /* use Tcl_EventuallyFree */
     Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
 #else
@@ -7697,7 +7697,7 @@ ip_eval(self, str) https://github.com/ruby/ruby/blob/trunk/ext/tk/tcltklib.c#L7697
     DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
 
     /* get result & free allocated memory */
-    ret = RARRAY_CONST_PTR(result)[0];
+    ret = RARRAY_AREF(result, 0);
 
 #if 0 /* use Tcl_EventuallyFree */
     Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
@@ -9196,7 +9196,7 @@ ip_invoke_with_position(argc, argv, obj, https://github.com/ruby/ruby/blob/trunk/ext/tk/tcltklib.c#L9196
     DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
 
     /* get result & free allocated memory */
-    ret = RARRAY_CONST_PTR(result)[0];
+    ret = RARRAY_AREF(result, 0);
 #if 0 /* use Tcl_EventuallyFree */
     Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
 #else
Index: ext/tk/tkutil/tkutil.c
===================================================================
--- ext/tk/tkutil/tkutil.c	(revision 52452)
+++ ext/tk/tkutil/tkutil.c	(revision 52453)
@@ -371,8 +371,8 @@ ary2list(ary, enc_flag, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L371
     /* size = RARRAY_LEN(ary); */
     size = 0;
     for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
-        if (RB_TYPE_P(RARRAY_CONST_PTR(ary)[idx], T_HASH)) {
-            size += 2 * RHASH_SIZE(RARRAY_CONST_PTR(ary)[idx]);
+        if (RB_TYPE_P(RARRAY_AREF(ary, idx), T_HASH)) {
+            size += 2 * RHASH_SIZE(RARRAY_AREF(ary, idx));
         } else {
             size++;
         }
@@ -380,7 +380,7 @@ ary2list(ary, enc_flag, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L380
 
     dst = rb_ary_new2(size);
     for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
-        val = RARRAY_CONST_PTR(ary)[idx];
+        val = RARRAY_AREF(ary, idx);
         str_val = Qnil;
         switch(TYPE(val)) {
         case T_ARRAY:
@@ -411,7 +411,7 @@ ary2list(ary, enc_flag, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L411
             }
             size2 = RARRAY_LEN(val);
             for(idx2 = 0; idx2 < size2; idx2++) {
-                val2 = RARRAY_CONST_PTR(val)[idx2];
+                val2 = RARRAY_AREF(val, idx2);
                 switch(TYPE(val2)) {
                 case T_ARRAY:
                     str_val = ary2list(val2, enc_flag, self);
@@ -472,7 +472,7 @@ ary2list(ary, enc_flag, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L472
 
     if (RTEST(dst_enc) && !NIL_P(sys_enc)) {
         for(idx = 0; idx < RARRAY_LEN(dst); idx++) {
-            str_val = RARRAY_CONST_PTR(dst)[idx];
+            str_val = RARRAY_AREF(dst, idx);
             if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
                 str_val = rb_funcall(self, ID_toUTF8, 1, str_val);
             } else {
@@ -525,7 +525,7 @@ ary2list2(ary, enc_flag, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L525
     size = RARRAY_LEN(ary);
     dst = rb_ary_new2(size);
     for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
-        val = RARRAY_CONST_PTR(ary)[idx];
+        val = RARRAY_AREF(ary, idx);
         str_val = Qnil;
         switch(TYPE(val)) {
         case T_ARRAY:
@@ -566,7 +566,7 @@ ary2list2(ary, enc_flag, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L566
 
     if (RTEST(dst_enc) && !NIL_P(sys_enc)) {
         for(idx = 0; idx < RARRAY_LEN(dst); idx++) {
-            str_val = RARRAY_CONST_PTR(dst)[idx];
+            str_val = RARRAY_AREF(dst, idx);
             if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
                 str_val = rb_funcall(self, ID_toUTF8, 1, str_val);
             } else {
@@ -608,23 +608,23 @@ assoc2kv(assoc, ary, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L608
     len = RARRAY_LEN(assoc);
 
     for(i = 0; i < len; i++) {
-        pair = RARRAY_CONST_PTR(assoc)[i];
+        pair = RARRAY_AREF(assoc, i);
         if (!RB_TYPE_P(pair, T_ARRAY)) {
             rb_ary_push(dst, key2keyname(pair));
             continue;
         }
         switch(RARRAY_LEN(assoc)) {
         case 2:
-            rb_ary_push(dst, RARRAY_CONST_PTR(pair)[2]);
+            rb_ary_push(dst, RARRAY_AREF(pair, 2));
 
         case 1:
-            rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
+            rb_ary_push(dst, key2keyname(RARRAY_AREF(pair, 0)));
 
         case 0:
             continue;
 
         default:
-            rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
+            rb_ary_push(dst, key2keyname(RARRAY_AREF(pair, 0)));
 
             val = rb_ary_new2(RARRAY_LEN(pair) - 1);
             rb_ary_cat(val, RARRAY_CONST_PTR(pair) + 1, RARRAY_LEN(pair) - 1);
@@ -654,23 +654,23 @@ assoc2kv_enc(assoc, ary, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L654
     len = RARRAY_LEN(assoc);
 
     for(i = 0; i < len; i++) {
-        pair = RARRAY_CONST_PTR(assoc)[i];
+        pair = RARRAY_AREF(assoc, i);
         if (!RB_TYPE_P(pair, T_ARRAY)) {
             rb_ary_push(dst, key2keyname(pair));
             continue;
         }
         switch(RARRAY_LEN(assoc)) {
         case 2:
-            rb_ary_push(dst, get_eval_string_core(RARRAY_CONST_PTR(pair)[2], Qtrue, self));
+            rb_ary_push(dst, get_eval_string_core(RARRAY_AREF(pair, 2), Qtrue, self));
 
         case 1:
-            rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
+            rb_ary_push(dst, key2keyname(RARRAY_AREF(pair, 0)));
 
         case 0:
             continue;
 
         default:
-            rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
+            rb_ary_push(dst, key2keyname(RARRAY_AREF(pair, 0)));
 
             val = rb_ary_new2(RARRAY_LEN(pair) - 1);
             rb_ary_cat(val, RARRAY_CONST_PTR(pair) + 1, RARRAY_LEN(pair) - 1);
@@ -694,7 +694,7 @@ push_kv(key, val, args) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L694
 {
     volatile VALUE ary;
 
-    ary = RARRAY_CONST_PTR(args)[0];
+    ary = RARRAY_AREF(args, 0);
 
 #if 0
     rb_ary_push(ary, key2keyname(key));
@@ -704,7 +704,7 @@ push_kv(key, val, args) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L704
 
     if (val == TK_None) return ST_CHECK;
 
-    rb_ary_push(ary, get_eval_string_core(val, Qnil, RARRAY_CONST_PTR(args)[1]));
+    rb_ary_push(ary, get_eval_string_core(val, Qnil, RARRAY_AREF(args, 1)));
 
     return ST_CHECK;
 }
@@ -735,20 +735,20 @@ push_kv_enc(key, val, args) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L735
 {
     volatile VALUE ary;
 
-    ary = RARRAY_CONST_PTR(args)[0];
+    ary = RARRAY_AREF(args, 0);
 
 #if 0
     rb_ary_push(ary, key2keyname(key));
     if (val != TK_None) {
         rb_ary_push(ary, get_eval_string_core(val, Qtrue,
-                                              RARRAY_CONST_PTR(args)[1]));
+                                              RARRAY_AREF(args, 1)));
     }
 #endif
     rb_ary_push(ary, key2keyname(key));
 
     if (val == TK_None) return ST_CHECK;
 
-    rb_ary_push(ary, get_eval_string_core(val, Qtrue, RARRAY_CONST_PTR(args)[1]));
+    rb_ary_push(ary, get_eval_string_core(val, Qtrue, RARRAY_AREF(args, 1)));
 
     return ST_CHECK;
 }
@@ -1494,7 +1494,7 @@ cbsubst_get_subst_key(self, str) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1494
     ptr = buf = RSTRING_PTR(ret);
 
     for(i = 0; i < len; i++) {
-      VALUE keyval = RARRAY_CONST_PTR(list)[i];
+      VALUE keyval = RARRAY_AREF(list, i);
       const char *key = (Check_Type(keyval, T_STRING), StringValueCStr(keyval));
       if (*key == '%') {
 	if (*(key + 2) == '\0') {
@@ -1593,7 +1593,7 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1593
    */
   len = RARRAY_LEN(key_inf);
   for(idx = 0; idx < len; idx++) {
-    inf = RARRAY_CONST_PTR(key_inf)[idx];
+    inf = RARRAY_AREF(key_inf, idx);
     if (!RB_TYPE_P(inf, T_ARRAY)) continue;
     infp = RARRAY_CONST_PTR(inf);
 
@@ -1617,7 +1617,7 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1617
    */
   len = RARRAY_LEN(longkey_inf);
   for(idx = 0; idx < len; idx++) {
-    inf = RARRAY_CONST_PTR(longkey_inf)[idx];
+    inf = RARRAY_AREF(longkey_inf, idx);
     if (!RB_TYPE_P(inf, T_ARRAY)) continue;
     infp = RARRAY_CONST_PTR(inf);
 
@@ -1643,7 +1643,7 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1643
   len = RARRAY_LEN(proc_inf);
   for(idx = 0; idx < len; idx++) {
     VALUE type, proc;
-    inf = RARRAY_CONST_PTR(proc_inf)[idx];
+    inf = RARRAY_AREF(proc_inf, idx);
     if (!RB_TYPE_P(inf, T_ARRAY)) continue;
     if (RARRAY_LEN(inf) < 2) continue;
     type = rb_ary_entry(inf, 0);
@@ -1703,10 +1703,10 @@ cbsubst_scan_args(self, arg_key, val_ary https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1703
       }
 
       if (NIL_P(proc)) {
-	rb_ary_push(dst, RARRAY_CONST_PTR(val_ary)[idx]);
+	rb_ary_push(dst, RARRAY_AREF(val_ary, idx));
       } else {
 	rb_ary_push(dst, rb_funcall(proc, ID_call, 1,
-				    RARRAY_CONST_PTR(val_ary)[idx]));
+				    RARRAY_AREF(val_ary, idx)));
       }
     }
 
Index: ext/openssl/ossl_ssl.c
===================================================================
--- ext/openssl/ossl_ssl.c	(revision 52452)
+++ ext/openssl/ossl_ssl.c	(revision 52453)
@@ -759,7 +759,7 @@ ossl_sslctx_setup(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L759
     if(!NIL_P(val)){
 	if (RB_TYPE_P(val, T_ARRAY)) {
 	    for(i = 0; i < RARRAY_LEN(val); i++){
-		client_ca = GetX509CertPtr(RARRAY_CONST_PTR(val)[i]);
+		client_ca = GetX509CertPtr(RARRAY_AREF(val, i));
         	if (!SSL_CTX_add_client_CA(ctx, client_ca)){
 		    /* Copies X509_NAME => FREE it. */
         	    ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
Index: ext/openssl/ossl_ocsp.c
===================================================================
--- ext/openssl/ossl_ocsp.c	(revision 52452)
+++ ext/openssl/ossl_ocsp.c	(revision 52453)
@@ -682,7 +682,7 @@ ossl_ocspbres_add_status(VALUE self, VAL https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ocsp.c#L682
 	/* All ary's members should be X509Extension */
 	Check_Type(ext, T_ARRAY);
 	for (i = 0; i < RARRAY_LEN(ext); i++)
-	    OSSL_Check_Kind(RARRAY_CONST_PTR(ext)[i], cX509Ext);
+	    OSSL_Check_Kind(RARRAY_AREF(ext, i), cX509Ext);
     }
 
     error = 0;
@@ -711,7 +711,7 @@ ossl_ocspbres_add_status(VALUE self, VAL https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ocsp.c#L711
 	sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free);
 	single->singleExtensions = NULL;
 	for(i = 0; i < RARRAY_LEN(ext); i++){
-	    x509ext = DupX509ExtPtr(RARRAY_CONST_PTR(ext)[i]);
+	    x509ext = DupX509ExtPtr(RARRAY_AREF(ext, i));
 	    if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
 		X509_EXTENSION_free(x509ext);
 		error = 1;
Index: ext/openssl/ossl_x509req.c
===================================================================
--- ext/openssl/ossl_x509req.c	(revision 52452)
+++ ext/openssl/ossl_x509req.c	(revision 52453)
@@ -423,13 +423,13 @@ ossl_x509req_set_attributes(VALUE self, https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509req.c#L423
 
     Check_Type(ary, T_ARRAY);
     for (i=0;i<RARRAY_LEN(ary); i++) {
-	OSSL_Check_Kind(RARRAY_CONST_PTR(ary)[i], cX509Attr);
+	OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Attr);
     }
     GetX509Req(self, req);
     sk_X509_ATTRIBUTE_pop_free(req->req_info->attributes, X509_ATTRIBUTE_free);
     req->req_info->attributes = NULL;
     for (i=0;i<RARRAY_LEN(ary); i++) {
-	item = RARRAY_CONST_PTR(ary)[i];
+	item = RARRAY_AREF(ary, i);
 	attr = DupX509AttrPtr(item);
 	if (!X509_REQ_add1_attr(req, attr)) {
 	    ossl_raise(eX509ReqError, NULL);
Index: ext/openssl/ossl_x509crl.c
===================================================================
--- ext/openssl/ossl_x509crl.c	(revision 52452)
+++ ext/openssl/ossl_x509crl.c	(revision 52453)
@@ -307,13 +307,13 @@ ossl_x509crl_set_revoked(VALUE self, VAL https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509crl.c#L307
     Check_Type(ary, T_ARRAY);
     /* All ary members should be X509 Revoked */
     for (i=0; i<RARRAY_LEN(ary); i++) {
-	OSSL_Check_Kind(RARRAY_CONST_PTR(ary)[i], cX509Rev);
+	OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Rev);
     }
     GetX509CRL(self, crl);
     sk_X509_REVOKED_pop_free(crl->crl->revoked, X509_REVOKED_free);
     crl->crl->revoked = NULL;
     for (i=0; i<RA (... truncated)

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

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