diff options
| author | Simon Tatham <anakin@pobox.com> | 2005-10-22 16:27:54 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2005-10-22 16:27:54 +0000 |
| commit | 23ab000b7b038b6810e48a71a94b8287c20a6047 (patch) | |
| tree | 1e8bcd5adc7c7d3b8179a954bc0e7c1c50cec7af | |
| parent | 4faecc77264b6d3e84ae24707af5593490f36796 (diff) | |
| download | puzzles-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.c | 12 | ||||
| -rw-r--r-- | devel.but | 6 | ||||
| -rw-r--r-- | map.c | 2 | ||||
| -rw-r--r-- | midend.c | 4 | ||||
| -rw-r--r-- | net.c | 2 | ||||
| -rw-r--r-- | puzzles.h | 2 | ||||
| -rw-r--r-- | random.c | 2 |
7 files changed, 15 insertions, 15 deletions
@@ -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++) { @@ -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 @@ -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; @@ -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 @@ -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; @@ -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); @@ -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; |