diff options
| author | Simon Tatham <anakin@pobox.com> | 2023-04-20 13:56:44 +0100 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2023-04-20 17:22:23 +0100 |
| commit | f21c7d27664bc43d3e5a9401756860c03055c3aa (patch) | |
| tree | 132993b10b21f8be6e559174c50a3ac12b5901fe | |
| parent | 11a8149d673d96bec17d6487b5fa95b5bf5ffd6b (diff) | |
| download | puzzles-f21c7d27664bc43d3e5a9401756860c03055c3aa.zip puzzles-f21c7d27664bc43d3e5a9401756860c03055c3aa.tar.gz puzzles-f21c7d27664bc43d3e5a9401756860c03055c3aa.tar.bz2 puzzles-f21c7d27664bc43d3e5a9401756860c03055c3aa.tar.xz | |
Consistently use snew_dsf to allocate dsfs.
All remaining cases where a dsf was allocated via snewn(foo, int) are
removed by this change.
| -rw-r--r-- | bridges.c | 2 | ||||
| -rw-r--r-- | filling.c | 2 | ||||
| -rw-r--r-- | galaxies.c | 2 | ||||
| -rw-r--r-- | loopy.c | 4 | ||||
| -rw-r--r-- | pearl.c | 2 | ||||
| -rw-r--r-- | singles.c | 2 | ||||
| -rw-r--r-- | slant.c | 4 | ||||
| -rw-r--r-- | tracks.c | 6 |
8 files changed, 11 insertions, 13 deletions
@@ -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; @@ -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); @@ -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); @@ -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; @@ -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); /* @@ -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) { @@ -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; @@ -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++) { |