random.c: default seed mark
* random.c (Init_Random_default): since seed is marked by random_mark, no needs to mark itself as a global variable. allocate Random instance before making the seed value, to get rid of the potential risk of GC during the allocation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
80c9b6646e
commit
72c4fc7283
7
random.c
7
random.c
@ -1544,13 +1544,10 @@ Init_Random_default(void)
|
|||||||
{
|
{
|
||||||
rb_random_t *r = &default_rand;
|
rb_random_t *r = &default_rand;
|
||||||
struct MT *mt = &r->mt;
|
struct MT *mt = &r->mt;
|
||||||
VALUE v;
|
VALUE v = TypedData_Wrap_Struct(rb_cRandom, &random_data_type, r);
|
||||||
|
|
||||||
r->seed = init_randomseed(mt);
|
|
||||||
rb_global_variable(&r->seed);
|
|
||||||
|
|
||||||
v = TypedData_Wrap_Struct(rb_cRandom, &random_data_type, r);
|
|
||||||
rb_gc_register_mark_object(v);
|
rb_gc_register_mark_object(v);
|
||||||
|
r->seed = init_randomseed(mt);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user