aboutsummaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
Diffstat (limited to 'random.c')
-rw-r--r--random.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/random.c b/random.c
index 107649c..4fcdda5 100644
--- a/random.c
+++ b/random.c
@@ -221,6 +221,16 @@ random_state *random_init(char *seed, int len)
return state;
}
+random_state *random_copy(random_state *tocopy)
+{
+ random_state *result;
+ result = snew(random_state);
+ memcpy(result->seedbuf, tocopy->seedbuf, sizeof(result->seedbuf));
+ memcpy(result->databuf, tocopy->databuf, sizeof(result->databuf));
+ result->pos = tocopy->pos;
+ return result;
+}
+
unsigned long random_bits(random_state *state, int bits)
{
unsigned long ret = 0;