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

ruby-changes:33278

From: nobu <ko1@a...>
Date: Mon, 17 Mar 2014 17:21:52 +0900 (JST)
Subject: [ruby-changes:33278] nobu:r45357 (trunk): process.c: constify

nobu	2014-03-17 17:21:47 +0900 (Mon, 17 Mar 2014)

  New Revision: 45357

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

  Log:
    process.c: constify
    
    * process.c (rb_execarg_new, rb_execarg_init): constify argv.

  Modified files:
    trunk/internal.h
    trunk/io.c
    trunk/process.c
Index: io.c
===================================================================
--- io.c	(revision 45356)
+++ io.c	(revision 45357)
@@ -6225,10 +6225,8 @@ rb_io_s_popen(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/io.c#L6225
 	    rb_raise(rb_eArgError, "too many arguments");
 	}
 #endif
-	tmp = rb_ary_dup(tmp);
-	RBASIC_CLEAR_CLASS(tmp);
 	execarg_obj = rb_execarg_new((int)len, RARRAY_CONST_PTR(tmp), FALSE);
-	rb_ary_clear(tmp);
+	RB_GC_GUARD(tmp);
     }
     else {
 	SafeStringValue(pname);
Index: process.c
===================================================================
--- process.c	(revision 45356)
+++ process.c	(revision 45357)
@@ -2198,7 +2198,7 @@ rb_exec_fillarg(VALUE prog, int argc, VA https://github.com/ruby/ruby/blob/trunk/process.c#L2198
 }
 
 VALUE
-rb_execarg_new(int argc, VALUE *argv, int accept_shell)
+rb_execarg_new(int argc, const VALUE *argv, int accept_shell)
 {
     VALUE execarg_obj;
     struct rb_execarg *eargp;
@@ -2217,13 +2217,17 @@ rb_execarg_get(VALUE execarg_obj) https://github.com/ruby/ruby/blob/trunk/process.c#L2217
 }
 
 VALUE
-rb_execarg_init(int argc, VALUE *argv, int accept_shell, VALUE execarg_obj)
+rb_execarg_init(int argc, const VALUE *orig_argv, int accept_shell, VALUE execarg_obj)
 {
     struct rb_execarg *eargp = rb_execarg_get(execarg_obj);
     VALUE prog, ret;
     VALUE env = Qnil, opthash = Qnil;
+    VALUE argv_buf;
+    VALUE *argv = ALLOCV_N(VALUE, argv_buf, argc);
+    MEMCPY(argv, orig_argv, VALUE, argc);
     prog = rb_exec_getargs(&argc, &argv, accept_shell, &env, &opthash);
     rb_exec_fillarg(prog, argc, argv, env, opthash, execarg_obj);
+    ALLOCV_END(argv_buf);
     ret = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name;
     RB_GC_GUARD(execarg_obj);
     return ret;
Index: internal.h
===================================================================
--- internal.h	(revision 45356)
+++ internal.h	(revision 45357)
@@ -963,9 +963,9 @@ VALUE rb_int_positive_pow(long x, unsign https://github.com/ruby/ruby/blob/trunk/internal.h#L963
 /* process.c */
 int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
 rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen);
-VALUE rb_execarg_new(int argc, VALUE *argv, int accept_shell);
+VALUE rb_execarg_new(int argc, const VALUE *argv, int accept_shell);
 struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous.  needs GC guard. */
-VALUE rb_execarg_init(int argc, VALUE *argv, int accept_shell, VALUE execarg_obj);
+VALUE rb_execarg_init(int argc, const VALUE *argv, int accept_shell, VALUE execarg_obj);
 int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
 void rb_execarg_fixup(VALUE execarg_obj);
 int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);

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

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