mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Consistently use snew_dsf to allocate dsfs.
All remaining cases where a dsf was allocated via snewn(foo, int) are removed by this change.
This commit is contained in:
@ -1771,7 +1771,7 @@ static game_state *new_state(const game_params *params)
|
|||||||
|
|
||||||
ret->solver = snew(struct solver_state);
|
ret->solver = snew(struct solver_state);
|
||||||
ret->solver->dsf = snew_dsf(wh);
|
ret->solver->dsf = snew_dsf(wh);
|
||||||
ret->solver->tmpdsf = snewn(wh, int);
|
ret->solver->tmpdsf = snew_dsf(wh);
|
||||||
|
|
||||||
ret->solver->refcount = 1;
|
ret->solver->refcount = 1;
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ static void make_board(int *board, int w, int h, random_state *rs) {
|
|||||||
* contains a shuffled list of numbers {0, ..., sz-1}. */
|
* contains a shuffled list of numbers {0, ..., sz-1}. */
|
||||||
for (i = 0; i < sz; ++i) board[i] = i;
|
for (i = 0; i < sz; ++i) board[i] = i;
|
||||||
|
|
||||||
dsf = snewn(sz, int);
|
dsf = snew_dsf(sz);
|
||||||
retry:
|
retry:
|
||||||
dsf_init(dsf, sz);
|
dsf_init(dsf, sz);
|
||||||
shuffle(board, sz, sizeof (int), rs);
|
shuffle(board, sz, sizeof (int), rs);
|
||||||
|
@ -3959,7 +3959,7 @@ static void game_print(drawing *dr, const game_state *state, int sz)
|
|||||||
/*
|
/*
|
||||||
* Get the completion information.
|
* Get the completion information.
|
||||||
*/
|
*/
|
||||||
dsf = snewn(w * h, int);
|
dsf = snew_dsf(w * h);
|
||||||
colours = snewn(w * h, int);
|
colours = snewn(w * h, int);
|
||||||
check_complete(state, dsf, colours);
|
check_complete(state, dsf, colours);
|
||||||
|
|
||||||
|
4
loopy.c
4
loopy.c
@ -455,7 +455,7 @@ static solver_state *dup_solver_state(const solver_state *sstate) {
|
|||||||
ret->solver_status = sstate->solver_status;
|
ret->solver_status = sstate->solver_status;
|
||||||
ret->diff = sstate->diff;
|
ret->diff = sstate->diff;
|
||||||
|
|
||||||
ret->dotdsf = snewn(num_dots, int);
|
ret->dotdsf = snew_dsf(num_dots);
|
||||||
ret->looplen = snewn(num_dots, int);
|
ret->looplen = snewn(num_dots, int);
|
||||||
dsf_copy(ret->dotdsf, sstate->dotdsf, num_dots);
|
dsf_copy(ret->dotdsf, sstate->dotdsf, num_dots);
|
||||||
memcpy(ret->looplen, sstate->looplen,
|
memcpy(ret->looplen, sstate->looplen,
|
||||||
@ -485,7 +485,7 @@ static solver_state *dup_solver_state(const solver_state *sstate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sstate->linedsf) {
|
if (sstate->linedsf) {
|
||||||
ret->linedsf = snewn(num_edges, int);
|
ret->linedsf = snew_dsf(num_edges);
|
||||||
dsf_copy(ret->linedsf, sstate->linedsf, num_edges);
|
dsf_copy(ret->linedsf, sstate->linedsf, num_edges);
|
||||||
} else {
|
} else {
|
||||||
ret->linedsf = NULL;
|
ret->linedsf = NULL;
|
||||||
|
2
pearl.c
2
pearl.c
@ -349,7 +349,7 @@ static int pearl_solve(int w, int h, char *clues, char *result,
|
|||||||
* We maintain a dsf of connected squares, together with a
|
* We maintain a dsf of connected squares, together with a
|
||||||
* count of the size of each equivalence class.
|
* count of the size of each equivalence class.
|
||||||
*/
|
*/
|
||||||
dsf = snewn(w*h, int);
|
dsf = snew_dsf(w*h);
|
||||||
dsfsize = snewn(w*h, int);
|
dsfsize = snewn(w*h, int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -498,7 +498,7 @@ static int check_rowcol(game_state *state, int starti, int di, int sz, unsigned
|
|||||||
|
|
||||||
static bool check_complete(game_state *state, unsigned flags)
|
static bool check_complete(game_state *state, unsigned flags)
|
||||||
{
|
{
|
||||||
int *dsf = snewn(state->n, int);
|
int *dsf = snew_dsf(state->n);
|
||||||
int x, y, i, error = 0, nwhite, w = state->w, h = state->h;
|
int x, y, i, error = 0, nwhite, w = state->w, h = state->h;
|
||||||
|
|
||||||
if (flags & CC_MARK_ERRORS) {
|
if (flags & CC_MARK_ERRORS) {
|
||||||
|
4
slant.c
4
slant.c
@ -312,10 +312,10 @@ static struct solver_scratch *new_scratch(int w, int h)
|
|||||||
{
|
{
|
||||||
int W = w+1, H = h+1;
|
int W = w+1, H = h+1;
|
||||||
struct solver_scratch *ret = snew(struct solver_scratch);
|
struct solver_scratch *ret = snew(struct solver_scratch);
|
||||||
ret->connected = snewn(W*H, int);
|
ret->connected = snew_dsf(W*H);
|
||||||
ret->exits = snewn(W*H, int);
|
ret->exits = snewn(W*H, int);
|
||||||
ret->border = snewn(W*H, bool);
|
ret->border = snewn(W*H, bool);
|
||||||
ret->equiv = snewn(w*h, int);
|
ret->equiv = snew_dsf(w*h);
|
||||||
ret->slashval = snewn(w*h, signed char);
|
ret->slashval = snewn(w*h, signed char);
|
||||||
ret->vbitmap = snewn(w*h, unsigned char);
|
ret->vbitmap = snewn(w*h, unsigned char);
|
||||||
return ret;
|
return ret;
|
||||||
|
6
tracks.c
6
tracks.c
@ -1373,8 +1373,7 @@ static int solve_check_loop(game_state *state)
|
|||||||
/* TODO eventually we should pull this out into a solver struct and keep it
|
/* TODO eventually we should pull this out into a solver struct and keep it
|
||||||
updated as we connect squares. For now we recreate it every time we try
|
updated as we connect squares. For now we recreate it every time we try
|
||||||
this particular solver step. */
|
this particular solver step. */
|
||||||
dsf = snewn(w*h, int);
|
dsf = snew_dsf(w*h);
|
||||||
dsf_init(dsf, w*h);
|
|
||||||
|
|
||||||
/* Work out the connectedness of the current loop set. */
|
/* Work out the connectedness of the current loop set. */
|
||||||
for (x = 0; x < w; x++) {
|
for (x = 0; x < w; x++) {
|
||||||
@ -1878,8 +1877,7 @@ static bool check_completion(game_state *state, bool mark)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dsf = snewn(w*h, int);
|
dsf = snew_dsf(w*h);
|
||||||
dsf_init(dsf, w*h);
|
|
||||||
|
|
||||||
for (x = 0; x < w; x++) {
|
for (x = 0; x < w; x++) {
|
||||||
for (y = 0; y < h; y++) {
|
for (y = 0; y < h; y++) {
|
||||||
|
Reference in New Issue
Block a user