1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

make Dir object WB protected.

* dir.c (dir_data_type): set RUBY_TYPED_WB_PROTECTED.
  Insert WBs for dir_data::path.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-06-01 15:18:51 +00:00
parent 44396dbe12
commit b4621c9aae

10
dir.c
View file

@ -437,7 +437,7 @@ VALUE rb_cDir;
struct dir_data { struct dir_data {
DIR *dir; DIR *dir;
VALUE path; const VALUE path;
rb_encoding *enc; rb_encoding *enc;
}; };
@ -466,7 +466,7 @@ dir_memsize(const void *ptr)
static const rb_data_type_t dir_data_type = { static const rb_data_type_t dir_data_type = {
"dir", "dir",
{dir_mark, dir_free, dir_memsize,}, {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); static VALUE dir_close(VALUE);
@ -487,7 +487,7 @@ dir_s_alloc(VALUE klass)
VALUE obj = TypedData_Make_Struct(klass, struct dir_data, &dir_data_type, dirp); VALUE obj = TypedData_Make_Struct(klass, struct dir_data, &dir_data_type, dirp);
dirp->dir = NULL; dirp->dir = NULL;
dirp->path = Qnil; RB_OBJ_WRITE(obj, &dirp->path, Qnil);
dirp->enc = NULL; dirp->enc = NULL;
return obj; return obj;
@ -536,7 +536,7 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
TypedData_Get_Struct(dir, struct dir_data, &dir_data_type, dp); TypedData_Get_Struct(dir, struct dir_data, &dir_data_type, dp);
if (dp->dir) closedir(dp->dir); if (dp->dir) closedir(dp->dir);
dp->dir = NULL; dp->dir = NULL;
dp->path = Qnil; RB_OBJ_WRITE(dir, &dp->path, Qnil);
dp->enc = fsenc; dp->enc = fsenc;
path = RSTRING_PTR(dirname); path = RSTRING_PTR(dirname);
dp->dir = opendir(path); dp->dir = opendir(path);
@ -559,7 +559,7 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
rb_syserr_fail_path(e, orig); rb_syserr_fail_path(e, orig);
} }
} }
dp->path = orig; RB_OBJ_WRITE(dir, &dp->path, orig);
return dir; return dir;
} }