diff --git a/auxiliary/divvy-test.c b/auxiliary/divvy-test.c index b6c9584..b7e3d6c 100644 --- a/auxiliary/divvy-test.c +++ b/auxiliary/divvy-test.c @@ -94,7 +94,7 @@ int main(int argc, char **argv) printf("\n"); } printf("\n"); - sfree(dsf); + dsf_free(dsf); } printf("%d retries needed for %d successes\n", fail_counter, tries); diff --git a/bridges.c b/bridges.c index 7043950..bb66c20 100644 --- a/bridges.c +++ b/bridges.c @@ -1820,8 +1820,8 @@ static game_state *dup_game(const game_state *state) static void free_game(game_state *state) { if (--state->solver->refcount <= 0) { - sfree(state->solver->dsf); - sfree(state->solver->tmpdsf); + dsf_free(state->solver->dsf); + dsf_free(state->solver->tmpdsf); sfree(state->solver); } diff --git a/divvy.c b/divvy.c index 91379e4..d21bd23 100644 --- a/divvy.c +++ b/divvy.c @@ -641,7 +641,7 @@ int *divvy_rectangle_attempt(int w, int h, int k, random_state *rs) */ sfree(order); sfree(tmp); - sfree(tmpdsf); + dsf_free(tmpdsf); sfree(own); sfree(sizes); sfree(queue); diff --git a/dominosa.c b/dominosa.c index 7a87e4b..8835bbb 100644 --- a/dominosa.c +++ b/dominosa.c @@ -510,7 +510,7 @@ static void solver_free_scratch(struct solver_scratch *sc) sfree(sc->pc_scratch); sfree(sc->pc_scratch2); sfree(sc->dc_scratch); - sfree(sc->dsf_scratch); + dsf_free(sc->dsf_scratch); sfree(sc); } diff --git a/dsf.c b/dsf.c index 832bb30..f967ffb 100644 --- a/dsf.c +++ b/dsf.c @@ -86,6 +86,11 @@ int *snew_dsf(int size) return ret; } +void dsf_free(int *dsf) +{ + sfree(dsf); +} + int dsf_canonify(int *dsf, int index) { return edsf_canonify(dsf, index, NULL); diff --git a/filling.c b/filling.c index 7e74e2d..6814a1a 100644 --- a/filling.c +++ b/filling.c @@ -464,7 +464,7 @@ retry: for (i = 0; i < sz; ++i) board[i] = dsf_size(dsf, i); merge_ones(board, w, h); - sfree(dsf); + dsf_free(dsf); } static void merge(int *dsf, int *connected, int a, int b) { @@ -1118,11 +1118,11 @@ static bool solver(const int *orig, int w, int h, char **solution) { (*solution)[sz + 1] = '\0'; } - sfree(ss.dsf); + dsf_free(ss.dsf); sfree(ss.board); sfree(ss.connected); sfree(ss.bm); - sfree(ss.bmdsf); + dsf_free(ss.bmdsf); sfree(ss.bmminsize); return !ss.nempty; @@ -1226,7 +1226,7 @@ static void minimize_clue_set(int *board, int w, int h, random_state *rs) } } sfree(next); - sfree(dsf); + dsf_free(dsf); /* * Now go through individual cells, in the same shuffled order, @@ -1617,7 +1617,7 @@ static game_state *execute_move(const game_state *state, const char *move) int *dsf = make_dsf(NULL, new_state->board, w, h); int i; for (i = 0; i < sz && new_state->board[i] == dsf_size(dsf, i); ++i); - sfree(dsf); + dsf_free(dsf); if (i == sz) new_state->completed = true; } @@ -1717,7 +1717,7 @@ static void game_free_drawstate(drawing *dr, game_drawstate *ds) sfree(ds->v); sfree(ds->flags); sfree(ds->border_scratch); - sfree(ds->dsf_scratch); + dsf_free(ds->dsf_scratch); sfree(ds); } diff --git a/galaxies.c b/galaxies.c index beb53fe..5297b4e 100644 --- a/galaxies.c +++ b/galaxies.c @@ -1817,7 +1817,7 @@ static solver_ctx *new_solver(game_state *state) static void free_solver(solver_ctx *sctx) { sfree(sctx->scratch); - sfree(sctx->dsf); + dsf_free(sctx->dsf); sfree(sctx->iscratch); sfree(sctx); } @@ -3240,7 +3240,7 @@ static bool check_complete(const game_state *state, int *dsf, int *colours) sfree(sqdata); if (free_dsf) - sfree(dsf); + dsf_free(dsf); return ret; } @@ -4095,7 +4095,7 @@ static void game_print(drawing *dr, const game_state *state, int sz) black : white), black); } - sfree(dsf); + dsf_free(dsf); sfree(colours); sfree(coords); } diff --git a/grid.c b/grid.c index 1bfc1ef..51db0e5 100644 --- a/grid.c +++ b/grid.c @@ -493,7 +493,7 @@ static void grid_trim_vigorously(grid *g) g->num_dots = newdots; sfree(dotpairs); - sfree(dsf); + dsf_free(dsf); sfree(dots); sfree(faces); } diff --git a/keen.c b/keen.c index cea8061..e886cbb 100644 --- a/keen.c +++ b/keen.c @@ -1284,7 +1284,7 @@ done sfree(order); sfree(revorder); sfree(singletons); - sfree(dsf); + dsf_free(dsf); sfree(clues); sfree(cluevals); sfree(soln); @@ -1310,12 +1310,12 @@ static const char *validate_desc(const game_params *params, const char *desc) dsf = snew_dsf(a); ret = parse_block_structure(&p, w, dsf); if (ret) { - sfree(dsf); + dsf_free(dsf); return ret; } if (*p != ',') { - sfree(dsf); + dsf_free(dsf); return "Expected ',' after block structure description"; } p++; @@ -1330,21 +1330,21 @@ static const char *validate_desc(const game_params *params, const char *desc) /* these clues need no validation */ } else if (*p == 'd' || *p == 's') { if (dsf_size(dsf, i) != 2) { - sfree(dsf); + dsf_free(dsf); return "Subtraction and division blocks must have area 2"; } } else if (!*p) { - sfree(dsf); + dsf_free(dsf); return "Too few clues for block structure"; } else { - sfree(dsf); + dsf_free(dsf); return "Unrecognised clue type"; } p++; while (*p && isdigit((unsigned char)*p)) p++; } } - sfree(dsf); + dsf_free(dsf); if (*p) return "Too many clues for block structure"; @@ -1459,7 +1459,7 @@ static void free_game(game_state *state) sfree(state->grid); sfree(state->pencil); if (--state->clues->refcount <= 0) { - sfree(state->clues->dsf); + dsf_free(state->clues->dsf); sfree(state->clues->clues); sfree(state->clues); } diff --git a/loopy.c b/loopy.c index 8f5a8a0..70e1106 100644 --- a/loopy.c +++ b/loopy.c @@ -426,7 +426,7 @@ static solver_state *new_solver_state(const game_state *state, int diff) { static void free_solver_state(solver_state *sstate) { if (sstate) { free_game(sstate->state); - sfree(sstate->dotdsf); + dsf_free(sstate->dotdsf); sfree(sstate->looplen); sfree(sstate->dot_solved); sfree(sstate->face_solved); @@ -437,7 +437,7 @@ static void free_solver_state(solver_state *sstate) { /* OK, because sfree(NULL) is a no-op */ sfree(sstate->dlines); - sfree(sstate->linedsf); + dsf_free(sstate->linedsf); sfree(sstate); } @@ -1769,7 +1769,7 @@ static bool check_completion(game_state *state) } sfree(component_state); - sfree(dsf); + dsf_free(dsf); return ret; } diff --git a/map.c b/map.c index 1122466..649821f 100644 --- a/map.c +++ b/map.c @@ -1802,7 +1802,7 @@ static const char *parse_edge_list(const game_params *params, err = NULL; /* no error */ out: - sfree(dsf); + dsf_free(dsf); return err; } diff --git a/net.c b/net.c index 79e29d0..79b4dd1 100644 --- a/net.c +++ b/net.c @@ -832,7 +832,7 @@ static int net_solver(int w, int h, unsigned char *tiles, sfree(tilestate); sfree(edgestate); sfree(deadends); - sfree(equivalence); + dsf_free(equivalence); return j; } diff --git a/palisade.c b/palisade.c index 458ce37..5acfaa4 100644 --- a/palisade.c +++ b/palisade.c @@ -565,11 +565,11 @@ static bool is_solved(const game_params *params, clue *clues, } } - sfree(dsf); + dsf_free(dsf); return true; error: - sfree(dsf); + dsf_free(dsf); return false; } @@ -594,7 +594,7 @@ static bool solver(const game_params *params, clue *clues, borderflag *borders) changed |= solver_equivalent_edges(&ctx); } while (changed); - sfree(ctx.dsf); + dsf_free(ctx.dsf); return is_solved(params, clues, borders); } @@ -648,7 +648,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, ++attempts; setmem(soln, '@', wh); - sfree(dsf); + dsf_free(dsf); dsf = divvy_rectangle(w, h, k, rs); for (r = 0; r < h; ++r) @@ -683,7 +683,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, sfree(scratch_borders); sfree(rim); sfree(shuf); - sfree(dsf); + dsf_free(dsf); char *output = snewn(wh + 1, char), *p = output; @@ -1252,8 +1252,8 @@ static void game_redraw(drawing *dr, game_drawstate *ds, draw_tile(dr, ds, r, c, ds->grid[i], clue); } - sfree(black_border_dsf); - sfree(yellow_border_dsf); + dsf_free(black_border_dsf); + dsf_free(yellow_border_dsf); } static float game_anim_length(const game_state *oldstate, diff --git a/pearl.c b/pearl.c index c668641..cf610e1 100644 --- a/pearl.c +++ b/pearl.c @@ -891,7 +891,7 @@ cleanup: } sfree(dsfsize); - sfree(dsf); + dsf_free(dsf); sfree(workspace); assert(ret >= 0); return ret; @@ -1582,7 +1582,7 @@ static bool check_completion(game_state *state, bool mark) for (y = 0; y < h; y++) { if (!dsf_update_completion(state, x, y, R, dsf) || !dsf_update_completion(state, x, y, D, dsf)) { - sfree(dsf); + dsf_free(dsf); return false; } } @@ -1665,7 +1665,7 @@ static bool check_completion(game_state *state, bool mark) * part of a single loop, for which our counter variables * nsilly,nloop,npath are enough. */ sfree(component_state); - sfree(dsf); + dsf_free(dsf); /* * Check that no clues are contradicted. This code is similar to diff --git a/puzzles.h b/puzzles.h index 27e1443..6f03b1d 100644 --- a/puzzles.h +++ b/puzzles.h @@ -427,6 +427,7 @@ char *button2label(int button); * dsf.c */ int *snew_dsf(int size); +void dsf_free(int *dsf); void print_dsf(int *dsf, int size); diff --git a/range.c b/range.c index 8b1b602..855a674 100644 --- a/range.c +++ b/range.c @@ -1492,7 +1492,7 @@ static bool find_errors(const game_state *state, bool *report) int biggest, canonical; if (!report) { - sfree(dsf); + dsf_free(dsf); goto found_error; } @@ -1517,7 +1517,7 @@ static bool find_errors(const game_state *state, bool *report) if (state->grid[i] != BLACK && dsf_canonify(dsf, i) != canonical) report[i] = true; } - sfree(dsf); + dsf_free(dsf); free_game(dup); return false; /* if report != NULL, this is ignored */ diff --git a/signpost.c b/signpost.c index f568488..306ac09 100644 --- a/signpost.c +++ b/signpost.c @@ -500,7 +500,7 @@ static void free_game(game_state *state) sfree(state->flags); sfree(state->next); sfree(state->prev); - sfree(state->dsf); + dsf_free(state->dsf); sfree(state->numsi); sfree(state); } diff --git a/singles.c b/singles.c index a977d10..cc079fe 100644 --- a/singles.c +++ b/singles.c @@ -562,7 +562,7 @@ static bool check_complete(game_state *state, unsigned flags) } } - sfree(dsf); + dsf_free(dsf); return !(error > 0); } diff --git a/slant.c b/slant.c index 13ba366..a07ee1c 100644 --- a/slant.c +++ b/slant.c @@ -325,10 +325,10 @@ static void free_scratch(struct solver_scratch *sc) { sfree(sc->vbitmap); sfree(sc->slashval); - sfree(sc->equiv); + dsf_free(sc->equiv); sfree(sc->border); sfree(sc->exits); - sfree(sc->connected); + dsf_free(sc->connected); sfree(sc); } @@ -1064,7 +1064,7 @@ static void slant_generate(int w, int h, signed char *soln, random_state *rs) } sfree(indices); - sfree(connected); + dsf_free(connected); } static char *new_game_desc(const game_params *params, random_state *rs, diff --git a/solo.c b/solo.c index 83bdeb8..7b8b296 100644 --- a/solo.c +++ b/solo.c @@ -3693,7 +3693,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, dsf_to_blocks (dsf, blocks, cr, cr); - sfree(dsf); + dsf_free(dsf); } else { /* basic Sudoku mode */ for (y = 0; y < cr; y++) for (x = 0; x < cr; x++) @@ -3926,7 +3926,7 @@ static const char *spec_to_dsf(const char **pdesc, int **pdsf, else if (*desc >= 'a' && *desc <= 'z') c = *desc - 'a' + 1; else { - sfree(dsf); + dsf_free(dsf); return "Invalid character in game description"; } desc++; @@ -3941,7 +3941,7 @@ static const char *spec_to_dsf(const char **pdesc, int **pdsf, * side of it. */ if (pos >= 2*cr*(cr-1)) { - sfree(dsf); + dsf_free(dsf); return "Too much data in block structure specification"; } @@ -3971,7 +3971,7 @@ static const char *spec_to_dsf(const char **pdesc, int **pdsf, * edge at the end. */ if (pos != 2*cr*(cr-1)+1) { - sfree(dsf); + dsf_free(dsf); return "Not enough data in block structure specification"; } @@ -4042,7 +4042,7 @@ static const char *validate_block_desc(const char **pdesc, int cr, int area, if (canons[c] == j) { counts[c]++; if (counts[c] > max_nr_squares) { - sfree(dsf); + dsf_free(dsf); sfree(canons); sfree(counts); return "A jigsaw block is too big"; @@ -4052,7 +4052,7 @@ static const char *validate_block_desc(const char **pdesc, int cr, int area, if (c == ncanons) { if (ncanons >= max_nr_blocks) { - sfree(dsf); + dsf_free(dsf); sfree(canons); sfree(counts); return "Too many distinct jigsaw blocks"; @@ -4064,14 +4064,14 @@ static const char *validate_block_desc(const char **pdesc, int cr, int area, } if (ncanons < min_nr_blocks) { - sfree(dsf); + dsf_free(dsf); sfree(canons); sfree(counts); return "Not enough distinct jigsaw blocks"; } for (c = 0; c < ncanons; c++) { if (counts[c] < min_nr_squares) { - sfree(dsf); + dsf_free(dsf); sfree(canons); sfree(counts); return "A jigsaw block is too small"; @@ -4081,7 +4081,7 @@ static const char *validate_block_desc(const char **pdesc, int cr, int area, sfree(counts); } - sfree(dsf); + dsf_free(dsf); return NULL; } @@ -4172,7 +4172,7 @@ static game_state *new_game(midend *me, const game_params *params, err = spec_to_dsf(&desc, &dsf, cr, area); assert(err == NULL); dsf_to_blocks(dsf, state->blocks, cr, cr); - sfree(dsf); + dsf_free(dsf); } else { int x, y; @@ -4190,7 +4190,7 @@ static game_state *new_game(midend *me, const game_params *params, err = spec_to_dsf(&desc, &dsf, cr, area); assert(err == NULL); dsf_to_blocks(dsf, state->kblocks, cr, area); - sfree(dsf); + dsf_free(dsf); make_blocks_from_whichblock(state->kblocks); assert(*desc == ','); diff --git a/tents.c b/tents.c index ca39401..bfb80ba 100644 --- a/tents.c +++ b/tents.c @@ -2302,7 +2302,7 @@ static int *find_errors(const game_state *state, char *grid) #undef TENT sfree(tmp); - sfree(dsf); + dsf_free(dsf); return ret; } diff --git a/tracks.c b/tracks.c index f4672d2..728e5a6 100644 --- a/tracks.c +++ b/tracks.c @@ -1412,7 +1412,7 @@ static int solve_check_loop(game_state *state) } } - sfree(dsf); + dsf_free(dsf); return did; } @@ -1605,7 +1605,7 @@ static int tracks_solve(game_state *state, int diff, int *max_diff_out) break; } - sfree(sc->dsf); + dsf_free(sc->dsf); if (max_diff_out) *max_diff_out = max_diff; @@ -1999,7 +1999,7 @@ static bool check_completion(game_state *state, bool mark) state->completed = ret; if (ret) set_flash_data(state); } - sfree(dsf); + dsf_free(dsf); return ret; } diff --git a/unfinished/separate.c b/unfinished/separate.c index 9ed1cac..b064f18 100644 --- a/unfinished/separate.c +++ b/unfinished/separate.c @@ -239,7 +239,7 @@ static struct solver_scratch *solver_scratch_new(int w, int h, int k) static void solver_scratch_free(struct solver_scratch *sc) { - sfree(sc->dsf); + dsf_free(sc->dsf); sfree(sc->size); sfree(sc->contents); sfree(sc->disconnect); @@ -615,7 +615,7 @@ static unsigned char *generate(int w, int h, int k, random_state *rs) retries = k*k; /* reset this counter, and continue */ } - sfree(dsf); + dsf_free(dsf); } while (m == 0); sfree(gen_lock); diff --git a/unfinished/slide.c b/unfinished/slide.c index fe573e8..d607b39 100644 --- a/unfinished/slide.c +++ b/unfinished/slide.c @@ -824,7 +824,7 @@ static void generate_board(int w, int h, int *rtx, int *rty, int *minmoves, } } - sfree(dsf); + dsf_free(dsf); sfree(list); sfree(tried_merge); sfree(board2); @@ -2260,7 +2260,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds, status_bar(dr, statusbuf); } - sfree(dsf); + dsf_free(dsf); sfree(board); }