ruby-changes:62858
From: Nobuyoshi <ko1@a...>
Date: Mon, 7 Sep 2020 20:08:32 +0900 (JST)
Subject: [ruby-changes:62858] 2b07b24bdf (master): Added `rb_random_base_init`
https://git.ruby-lang.org/ruby.git/commit/?id=2b07b24bdf From 2b07b24bdf15e4feeb9dae94a17999070cd77121 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 7 Sep 2020 18:56:39 +0900 Subject: Added `rb_random_base_init` To enclose the initialization of Random::Base part. diff --git a/ext/-test-/random/loop.c b/ext/-test-/random/loop.c index 4f7c800..ec4eff0 100644 --- a/ext/-test-/random/loop.c +++ b/ext/-test-/random/loop.c @@ -38,7 +38,7 @@ loop_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/ext/-test-/random/loop.c#L38 { 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; } diff --git a/include/ruby/random.h b/include/ruby/random.h index 1d45dc2..2e7ac75 100644 --- a/include/ruby/random.h +++ b/include/ruby/random.h @@ -71,6 +71,7 @@ typedef const rb_data_type_t rb_random_data_type_t; https://github.com/ruby/ruby/blob/trunk/include/ruby/random.h#L71 #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; diff --git a/random.c b/random.c index 4ceff37..587e93c 100644 --- a/random.c +++ b/random.c @@ -297,12 +297,19 @@ try_rand_if(VALUE obj, rb_random_t *rnd) https://github.com/ruby/ruby/blob/trunk/random.c#L297 } /* :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; } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/