summaryrefslogtreecommitdiff
path: root/ext/tk/tcltklib.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-04 07:27:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-04 07:27:10 +0000
commit3553a86eb51365cc524cf5c549b37770448d550d (patch)
tree9a96e1d3ccc6de7a94b8d884ddb946b3c3701de3 /ext/tk/tcltklib.c
parent52912db4a81f9b9b69ab9e9fcd95e22d086d4289 (diff)
ext: use RARRAY_CONST_PTR
* ext/bigdecimal/bigdecimal.c: use RARRAY_CONST_PTR just fore reference instead of RARRAY_PTR, to keep the array WB-protected. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/tcltklib.c')
-rw-r--r--ext/tk/tcltklib.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c
index 2906cb7281..fed21d3709 100644
--- a/ext/tk/tcltklib.c
+++ b/ext/tk/tcltklib.c
@@ -42,6 +42,9 @@ int rb_thread_check_trap_pending(void);
#define RARRAY_PTR(s) (RARRAY(s)->ptr)
#define RARRAY_LEN(s) (RARRAY(s)->len)
#endif
+#if !defined(RARRAY_CONST_PTR)
+#define RARRAY_CONST_PTR(s) (const VALUE *)RARRAY_PTR(s)
+#endif
#ifdef OBJ_UNTRUST
#define RbTk_OBJ_UNTRUST(x) do {OBJ_TAINT(x); OBJ_UNTRUST(x);} while (0)
@@ -1889,15 +1892,15 @@ set_max_block_time(self, time)
case T_BIGNUM:
/* time is micro-second value */
divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000));
- tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]);
- tcl_time.usec = NUM2LONG(RARRAY_PTR(divmod)[1]);
+ tcl_time.sec = NUM2LONG(RARRAY_CONST_PTR(divmod)[0]);
+ tcl_time.usec = NUM2LONG(RARRAY_CONST_PTR(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_PTR(divmod)[0]);
- tcl_time.usec = (long)(NUM2DBL(RARRAY_PTR(divmod)[1]) * 1000000);
+ tcl_time.sec = NUM2LONG(RARRAY_CONST_PTR(divmod)[0]);
+ tcl_time.usec = (long)(NUM2DBL(RARRAY_CONST_PTR(divmod)[1]) * 1000000);
default:
{
@@ -7210,7 +7213,7 @@ tk_funcall(func, argc, argv, obj)
DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
/* get result & free allocated memory */
- ret = RARRAY_PTR(result)[0];
+ ret = RARRAY_CONST_PTR(result)[0];
#if 0 /* use Tcl_EventuallyFree */
Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
#else
@@ -7694,7 +7697,7 @@ ip_eval(self, str)
DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
/* get result & free allocated memory */
- ret = RARRAY_PTR(result)[0];
+ ret = RARRAY_CONST_PTR(result)[0];
#if 0 /* use Tcl_EventuallyFree */
Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
@@ -9193,7 +9196,7 @@ ip_invoke_with_position(argc, argv, obj, position)
DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
/* get result & free allocated memory */
- ret = RARRAY_PTR(result)[0];
+ ret = RARRAY_CONST_PTR(result)[0];
#if 0 /* use Tcl_EventuallyFree */
Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
#else