aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-10-22 16:27:54 +0000
committerSimon Tatham <anakin@pobox.com>2005-10-22 16:27:54 +0000
commit23ab000b7b038b6810e48a71a94b8287c20a6047 (patch)
tree1e8bcd5adc7c7d3b8179a954bc0e7c1c50cec7af
parent4faecc77264b6d3e84ae24707af5593490f36796 (diff)
downloadpuzzles-23ab000b7b038b6810e48a71a94b8287c20a6047.zip
puzzles-23ab000b7b038b6810e48a71a94b8287c20a6047.tar.gz
puzzles-23ab000b7b038b6810e48a71a94b8287c20a6047.tar.bz2
puzzles-23ab000b7b038b6810e48a71a94b8287c20a6047.tar.xz
Cleanup: rename random_init() to random_new(), because it actually
_allocates_ a random_state rather than just initialising one passed in by the caller. [originally from svn r6412]
-rw-r--r--blackbox.c12
-rw-r--r--devel.but6
-rw-r--r--map.c2
-rw-r--r--midend.c4
-rw-r--r--net.c2
-rw-r--r--puzzles.h2
-rw-r--r--random.c2
7 files changed, 15 insertions, 15 deletions
diff --git a/blackbox.c b/blackbox.c
index dda036c..1889a19 100644
--- a/blackbox.c
+++ b/blackbox.c
@@ -692,9 +692,9 @@ static int check_guesses(game_state *state, int cagey)
* grid, so that repeating the same marking will give
* the same answer instead of a different one.
*/
- random_state *rs = random_init((char *)guesses->grid,
- (state->w+2)*(state->h+2) *
- sizeof(unsigned int));
+ random_state *rs = random_new((char *)guesses->grid,
+ (state->w+2)*(state->h+2) *
+ sizeof(unsigned int));
n = random_upto(rs, n);
random_free(rs);
for (i = 0; i < guesses->nlasers; i++) {
@@ -727,9 +727,9 @@ static int check_guesses(game_state *state, int cagey)
* grid, so that repeating the same marking will give
* the same answer instead of a different one.
*/
- random_state *rs = random_init((char *)guesses->grid,
- (state->w+2)*(state->h+2) *
- sizeof(unsigned int));
+ random_state *rs = random_new((char *)guesses->grid,
+ (state->w+2)*(state->h+2) *
+ sizeof(unsigned int));
n = random_upto(rs, n);
random_free(rs);
for (i = 0; i < guesses->nlasers; i++) {
diff --git a/devel.but b/devel.but
index ef43baa..88ff947 100644
--- a/devel.but
+++ b/devel.but
@@ -1478,7 +1478,7 @@ otherwise be obvious.
If a back end needs random numbers at some point during normal play,
it can create a fresh \c{random_state} by first calling
\c{get_random_seed} (\k{frontend-get-random-seed}) and then passing
-the returned seed data to \cw{random_init()}.
+the returned seed data to \cw{random_new()}.
This is likely not to be what you want. If a puzzle needs randomness
in the middle of play, it's likely to be more sensible to store some
@@ -3044,9 +3044,9 @@ generator has an \e{explicit} state object called a
\c{random_state}. One of these is managed by each mid-end, for
example, and passed to the back end to generate a game with.
-\S{utils-random-init} \cw{random_init()}
+\S{utils-random-init} \cw{random_new()}
-\c random_state *random_init(char *seed, int len);
+\c random_state *random_new(char *seed, int len);
Allocates, initialises and returns a new \c{random_state}. The input
data is used as the seed for the random number stream (i.e. using
diff --git a/map.c b/map.c
index 6302ef7..3b01d9b 100644
--- a/map.c
+++ b/map.c
@@ -1868,7 +1868,7 @@ static game_state *new_game(midend *me, game_params *params, char *desc)
* outlines by the judicious use of diagonally divided squares.
*/
{
- random_state *rs = random_init(desc, strlen(desc));
+ random_state *rs = random_new(desc, strlen(desc));
int *squares = snewn(wh, int);
int done_something;
diff --git a/midend.c b/midend.c
index 833cbef..249fb2b 100644
--- a/midend.c
+++ b/midend.c
@@ -102,7 +102,7 @@ midend *midend_new(frontend *fe, const game *ourgame,
me->frontend = fe;
me->ourgame = ourgame;
- me->random = random_init(randseed, randseedsize);
+ me->random = random_new(randseed, randseedsize);
me->nstates = me->statesize = me->statepos = 0;
me->states = NULL;
me->params = ourgame->default_params();
@@ -342,7 +342,7 @@ void midend_new_game(midend *me)
sfree(me->aux_info);
me->aux_info = NULL;
- rs = random_init(me->seedstr, strlen(me->seedstr));
+ rs = random_new(me->seedstr, strlen(me->seedstr));
/*
* If this midend has been instantiated without providing a
* drawing API, it is non-interactive. This means that it's
diff --git a/net.c b/net.c
index f8811a7..3e49b38 100644
--- a/net.c
+++ b/net.c
@@ -1804,7 +1804,7 @@ static game_ui *new_ui(game_state *state)
ui->cur_y = ui->cy = state->height / 2;
ui->cur_visible = FALSE;
get_random_seed(&seed, &seedsize);
- ui->rs = random_init(seed, seedsize);
+ ui->rs = random_new(seed, seedsize);
sfree(seed);
return ui;
diff --git a/puzzles.h b/puzzles.h
index a962bc3..659afa6 100644
--- a/puzzles.h
+++ b/puzzles.h
@@ -287,7 +287,7 @@ extern char ver[];
/*
* random.c
*/
-random_state *random_init(char *seed, int len);
+random_state *random_new(char *seed, int len);
random_state *random_copy(random_state *tocopy);
unsigned long random_bits(random_state *state, int bits);
unsigned long random_upto(random_state *state, unsigned long limit);
diff --git a/random.c b/random.c
index 4fcdda5..6d278a4 100644
--- a/random.c
+++ b/random.c
@@ -207,7 +207,7 @@ struct random_state {
int pos;
};
-random_state *random_init(char *seed, int len)
+random_state *random_new(char *seed, int len)
{
random_state *state;