mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Added rb_random_base_init
To enclose the initialization of Random::Base part.
This commit is contained in:
parent
4924011262
commit
2b07b24bdf
Notes:
git
2020-09-07 20:08:34 +09:00
3 changed files with 10 additions and 2 deletions
|
@ -38,7 +38,7 @@ loop_alloc(VALUE klass)
|
|||
{
|
||||
rand_loop_t *rnd;
|
||||
VALUE obj = TypedData_Make_Struct(klass, rand_loop_t, &random_loop_type, rnd);
|
||||
rnd->base.seed = INT2FIX(0);
|
||||
rb_random_base_init(&rnd->base);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ typedef const rb_data_type_t rb_random_data_type_t;
|
|||
#endif
|
||||
|
||||
void rb_random_mark(void *ptr);
|
||||
void rb_random_base_init(rb_random_t *rnd);
|
||||
double rb_int_pair_to_real(uint32_t a, uint32_t b, int excl);
|
||||
void rb_rand_bytes_int32(rb_random_get_int32_func *, rb_random_t *, void *, size_t);
|
||||
RUBY_EXTERN const rb_data_type_t rb_random_data_type;
|
||||
|
|
9
random.c
9
random.c
|
@ -296,13 +296,20 @@ try_rand_if(VALUE obj, rb_random_t *rnd)
|
|||
return rb_rand_if(obj);
|
||||
}
|
||||
|
||||
/* :nodoc: */
|
||||
void
|
||||
rb_random_base_init(rb_random_t *rnd)
|
||||
{
|
||||
rnd->seed = INT2FIX(0);
|
||||
}
|
||||
|
||||
/* :nodoc: */
|
||||
static VALUE
|
||||
random_alloc(VALUE klass)
|
||||
{
|
||||
rb_random_mt_t *rnd;
|
||||
VALUE obj = TypedData_Make_Struct(klass, rb_random_mt_t, &random_mt_type, rnd);
|
||||
rnd->base.seed = INT2FIX(0);
|
||||
rb_random_base_init(&rnd->base);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue