]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(__setstate_r): Allow call with same state array as currently used.
authorUlrich Drepper <drepper@redhat.com>
Thu, 10 Sep 1998 17:07:14 +0000 (17:07 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 10 Sep 1998 17:07:14 +0000 (17:07 +0000)
stdlib/random_r.c

index 6355097a936fbb7f20c56615447b3719486425de..d01f13383febf8883525f3c73dc4cffe9c98eee3 100644 (file)
@@ -243,8 +243,8 @@ __setstate_r (arg_state, buf)
      struct random_data *buf;
 {
   int32_t *new_state = (int32_t *) arg_state;
-  int type = new_state[0] % MAX_TYPES;
-  int rear = new_state[0] / MAX_TYPES;
+  int type;
+  int rear;
 
   if (buf == NULL)
     return -1;
@@ -254,6 +254,9 @@ __setstate_r (arg_state, buf)
   else
     buf->state[-1] = (MAX_TYPES * (buf->rptr - buf->state)) + buf->rand_type;
 
+  type = new_state[0] % MAX_TYPES;
+  rear = new_state[0] / MAX_TYPES;
+
   switch (type)
     {
     case TYPE_0: