aboutsummaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-08-01 11:27:01 +0000
committerSimon Tatham <anakin@pobox.com>2005-08-01 11:27:01 +0000
commit207c847553a978c6fcdb6269dc2b0add3c99a109 (patch)
tree51838ad41c29f4f28e457271ff3182c0725e91e2 /random.c
parente6132341c4a7ed22492fc41556489f8876dcdf18 (diff)
downloadpuzzles-207c847553a978c6fcdb6269dc2b0add3c99a109.zip
puzzles-207c847553a978c6fcdb6269dc2b0add3c99a109.tar.gz
puzzles-207c847553a978c6fcdb6269dc2b0add3c99a109.tar.bz2
puzzles-207c847553a978c6fcdb6269dc2b0add3c99a109.tar.xz
Various cleanups and clarifications to devel.but; some from Richard
B and some from me. Also an additional utility function `random_copy' from Richard B, which he says is useful in a new puzzle he's working on and which seems likely to come in handy again at some point. [originally from svn r6153]
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;