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

ruby-changes:33495

From: nobu <ko1@a...>
Date: Sat, 12 Apr 2014 22:11:19 +0900 (JST)
Subject: [ruby-changes:33495] nobu:r45576 (trunk): string.c: clear env self in symbol proc

nobu	2014-04-12 22:11:11 +0900 (Sat, 12 Apr 2014)

  New Revision: 45576

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

  Log:
    string.c: clear env self in symbol proc
    
    * string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear
      caller's self which is useless, so that it can get collected.
      [Fixes GH-592]

  Modified files:
    trunk/ChangeLog
    trunk/internal.h
    trunk/proc.c
    trunk/string.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45575)
+++ ChangeLog	(revision 45576)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Apr 12 22:11:10 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear
+	  caller's self which is useless, so that it can get collected.
+	  [Fixes GH-592]
+
 Sat Apr 12 09:26:48 2014  Eric Hodel  <drbrain@s...>
 
 	* ext/openssl/ossl_ocsp.c:  [DOC] Document OpenSSL::OCSP.
Index: string.c
===================================================================
--- string.c	(revision 45575)
+++ string.c	(revision 45576)
@@ -8506,6 +8506,7 @@ sym_to_proc(VALUE sym) https://github.com/ruby/ruby/blob/trunk/string.c#L8506
     }
     else {
 	proc = rb_proc_new(sym_call, (VALUE)id);
+	rb_block_clear_env_self(proc);
 	aryp[index] = sym;
 	aryp[index + 1] = proc;
 	return proc;
Index: proc.c
===================================================================
--- proc.c	(revision 45575)
+++ proc.c	(revision 45576)
@@ -710,6 +710,17 @@ rb_block_lambda(void) https://github.com/ruby/ruby/blob/trunk/proc.c#L710
 }
 
 VALUE
+rb_block_clear_env_self(VALUE proc)
+{
+    rb_proc_t *po;
+    rb_env_t *env;
+    GetProcPtr(proc, po);
+    GetEnvPtr(po->envval, env);
+    env->env[0] = Qnil;
+    return proc;
+}
+
+VALUE
 rb_f_lambda(void)
 {
     rb_warn("rb_f_lambda() is deprecated; use rb_block_proc() instead");
Index: internal.h
===================================================================
--- internal.h	(revision 45575)
+++ internal.h	(revision 45576)
@@ -758,6 +758,7 @@ ID rb_id_attrget(ID id); https://github.com/ruby/ruby/blob/trunk/internal.h#L758
 VALUE rb_proc_location(VALUE self);
 st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
 int rb_block_arity(void);
+VALUE rb_block_clear_env_self(VALUE proc);
 
 /* process.c */
 #define RB_MAX_GROUPS (65536)

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

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