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

ruby-changes:42921

From: nobu <ko1@a...>
Date: Sat, 14 May 2016 00:17:04 +0900 (JST)
Subject: [ruby-changes:42921] nobu:r54995 (trunk): random.c: fill_random_seed size

nobu	2016-05-14 00:16:56 +0900 (Sat, 14 May 2016)

  New Revision: 54995

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

  Log:
    random.c: fill_random_seed size
    
    * random.c (fill_random_seed): move the seed size to an argument.

  Modified files:
    trunk/random.c
Index: random.c
===================================================================
--- random.c	(revision 54994)
+++ random.c	(revision 54995)
@@ -543,14 +543,15 @@ fill_random_bytes(void *seed, size_t siz https://github.com/ruby/ruby/blob/trunk/random.c#L543
 }
 
 static void
-fill_random_seed(uint32_t seed[DEFAULT_SEED_CNT])
+fill_random_seed(uint32_t *seed, size_t cnt)
 {
     static int n = 0;
     struct timeval tv;
+    size_t len = cnt * sizeof(*seed);
 
-    memset(seed, 0, DEFAULT_SEED_LEN);
+    memset(seed, 0, len);
 
-    fill_random_bytes(seed, DEFAULT_SEED_LEN, TRUE);
+    fill_random_bytes(seed, len, TRUE);
 
     gettimeofday(&tv, 0);
     seed[0] ^= tv.tv_usec;
@@ -602,7 +603,7 @@ random_seed(void) https://github.com/ruby/ruby/blob/trunk/random.c#L603
 {
     VALUE v;
     uint32_t buf[DEFAULT_SEED_CNT];
-    fill_random_seed(buf);
+    fill_random_seed(buf, DEFAULT_SEED_CNT);
     v = make_seed_value(buf);
     explicit_bzero(buf, DEFAULT_SEED_LEN);
     return v;
@@ -1540,7 +1541,7 @@ Init_RandomSeedCore(void) https://github.com/ruby/ruby/blob/trunk/random.c#L1541
     struct MT mt;
     uint32_t initial_seed[DEFAULT_SEED_CNT];
 
-    fill_random_seed(initial_seed);
+    fill_random_seed(initial_seed, DEFAULT_SEED_CNT);
     init_by_array(&mt, initial_seed, DEFAULT_SEED_CNT);
 
     init_hashseed(&mt);
@@ -1555,7 +1556,7 @@ init_randomseed(struct MT *mt) https://github.com/ruby/ruby/blob/trunk/random.c#L1556
     uint32_t initial[DEFAULT_SEED_CNT];
     VALUE seed;
 
-    fill_random_seed(initial);
+    fill_random_seed(initial, DEFAULT_SEED_CNT);
     init_by_array(mt, initial, DEFAULT_SEED_CNT);
     seed = make_seed_value(initial);
     explicit_bzero(initial, DEFAULT_SEED_LEN);

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

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