diff --git a/bridges.c b/bridges.c index e51bfe9..b837e77 100644 --- a/bridges.c +++ b/bridges.c @@ -1771,7 +1771,7 @@ static game_state *new_state(const game_params *params) ret->solver = snew(struct solver_state); ret->solver->dsf = snew_dsf(wh); - ret->solver->tmpdsf = snewn(wh, int); + ret->solver->tmpdsf = snew_dsf(wh); ret->solver->refcount = 1; diff --git a/filling.c b/filling.c index 6814a1a..2164205 100644 --- a/filling.c +++ b/filling.c @@ -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}. */ for (i = 0; i < sz; ++i) board[i] = i; - dsf = snewn(sz, int); + dsf = snew_dsf(sz); retry: dsf_init(dsf, sz); shuffle(board, sz, sizeof (int), rs); diff --git a/galaxies.c b/galaxies.c index 5297b4e..dd6b684 100644 --- a/galaxies.c +++ b/galaxies.c @@ -3959,7 +3959,7 @@ static void game_print(drawing *dr, const game_state *state, int sz) /* * Get the completion information. */ - dsf = snewn(w * h, int); + dsf = snew_dsf(w * h); colours = snewn(w * h, int); check_complete(state, dsf, colours); diff --git a/loopy.c b/loopy.c index f06596e..e50931b 100644 --- a/loopy.c +++ b/loopy.c @@ -455,7 +455,7 @@ static solver_state *dup_solver_state(const solver_state *sstate) { ret->solver_status = sstate->solver_status; ret->diff = sstate->diff; - ret->dotdsf = snewn(num_dots, int); + ret->dotdsf = snew_dsf(num_dots); ret->looplen = snewn(num_dots, int); dsf_copy(ret->dotdsf, sstate->dotdsf, num_dots); memcpy(ret->looplen, sstate->looplen, @@ -485,7 +485,7 @@ static solver_state *dup_solver_state(const solver_state *sstate) { } if (sstate->linedsf) { - ret->linedsf = snewn(num_edges, int); + ret->linedsf = snew_dsf(num_edges); dsf_copy(ret->linedsf, sstate->linedsf, num_edges); } else { ret->linedsf = NULL; diff --git a/pearl.c b/pearl.c index cf610e1..ef2cd0a 100644 --- a/pearl.c +++ b/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 * count of the size of each equivalence class. */ - dsf = snewn(w*h, int); + dsf = snew_dsf(w*h); dsfsize = snewn(w*h, int); /* diff --git a/singles.c b/singles.c index cc079fe..5541ad5 100644 --- a/singles.c +++ b/singles.c @@ -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) { - 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; if (flags & CC_MARK_ERRORS) { diff --git a/slant.c b/slant.c index a07ee1c..e2d354e 100644 --- a/slant.c +++ b/slant.c @@ -312,10 +312,10 @@ static struct solver_scratch *new_scratch(int w, int h) { int W = w+1, H = h+1; 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->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->vbitmap = snewn(w*h, unsigned char); return ret; diff --git a/tracks.c b/tracks.c index 728e5a6..b1145d8 100644 --- a/tracks.c +++ b/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 updated as we connect squares. For now we recreate it every time we try this particular solver step. */ - dsf = snewn(w*h, int); - dsf_init(dsf, w*h); + dsf = snew_dsf(w*h); /* Work out the connectedness of the current loop set. */ 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_init(dsf, w*h); + dsf = snew_dsf(w*h); for (x = 0; x < w; x++) { for (y = 0; y < h; y++) {