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

ruby-changes:46875

From: ko1 <ko1@a...>
Date: Fri, 2 Jun 2017 00:18:56 +0900 (JST)
Subject: [ruby-changes:46875] ko1:r58990 (trunk): make Dir object WB protected.

ko1	2017-06-02 00:18:51 +0900 (Fri, 02 Jun 2017)

  New Revision: 58990

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

  Log:
    make Dir object WB protected.
    
    * dir.c (dir_data_type): set RUBY_TYPED_WB_PROTECTED.
      Insert WBs for dir_data::path.

  Modified files:
    trunk/dir.c
Index: dir.c
===================================================================
--- dir.c	(revision 58989)
+++ dir.c	(revision 58990)
@@ -437,7 +437,7 @@ VALUE rb_cDir; https://github.com/ruby/ruby/blob/trunk/dir.c#L437
 
 struct dir_data {
     DIR *dir;
-    VALUE path;
+    const VALUE path;
     rb_encoding *enc;
 };
 
@@ -466,7 +466,7 @@ dir_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/dir.c#L466
 static const rb_data_type_t dir_data_type = {
     "dir",
     {dir_mark, dir_free, dir_memsize,},
-    0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+    0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
 };
 
 static VALUE dir_close(VALUE);
@@ -487,7 +487,7 @@ dir_s_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/dir.c#L487
     VALUE obj = TypedData_Make_Struct(klass, struct dir_data, &dir_data_type, dirp);
 
     dirp->dir = NULL;
-    dirp->path = Qnil;
+    RB_OBJ_WRITE(obj, &dirp->path, Qnil);
     dirp->enc = NULL;
 
     return obj;
@@ -536,7 +536,7 @@ dir_initialize(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/dir.c#L536
     TypedData_Get_Struct(dir, struct dir_data, &dir_data_type, dp);
     if (dp->dir) closedir(dp->dir);
     dp->dir = NULL;
-    dp->path = Qnil;
+    RB_OBJ_WRITE(dir, &dp->path, Qnil);
     dp->enc = fsenc;
     path = RSTRING_PTR(dirname);
     dp->dir = opendir(path);
@@ -559,7 +559,7 @@ dir_initialize(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/dir.c#L559
 	    rb_syserr_fail_path(e, orig);
 	}
     }
-    dp->path = orig;
+    RB_OBJ_WRITE(dir, &dp->path, orig);
 
     return dir;
 }

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

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