int *dsf;
};
-struct solver_scratch *new_scratch(int w, int h)
+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);
return ret;
}
-void free_scratch(struct solver_scratch *sc)
+static void free_scratch(struct solver_scratch *sc)
{
sfree(sc->dsf);
sfree(sc);
static void free_game(game_state *state)
{
+ sfree(state->soln);
+ assert(state->clues);
+ if (--state->clues->refcount <= 0) {
+ sfree(state->clues->clues);
+ sfree(state->clues->dsf);
+ sfree(state->clues);
+ }
sfree(state);
}
if (ret != 1) {
sfree(soln);
if (ret == 0)
- return "This puzzle is not self-consistent";
+ *error = "This puzzle is not self-consistent";
else
- return "Unable to find a unique solution for this puzzle";
+ *error = "Unable to find a unique solution for this puzzle";
+ return NULL;
}
free_soln = TRUE;
}
for (x = 0; x < w; x++) {
int v = (soln[y*w+x] == bs ? -1 : +1);
if (state->soln[y*w+x] != v) {
- int len = sprintf(buf, ";%c%d,%d", v < 0 ? '\\' : '/', x, y);
+ int len = sprintf(buf, ";%c%d,%d", (int)(v < 0 ? '\\' : '/'), x, y);
if (movelen + len >= movesize) {
movesize = movelen + len + 256;
move = sresize(move, movesize, char);
v = -1;
}
- sprintf(buf, "%c%d,%d", v==-1 ? '\\' : v==+1 ? '/' : 'C', x, y);
+ sprintf(buf, "%c%d,%d", (int)(v==-1 ? '\\' : v==+1 ? '/' : 'C'), x, y);
return dupstr(buf);
}
static void game_free_drawstate(game_drawstate *ds)
{
+ sfree(ds->todraw);
sfree(ds->grid);
sfree(ds);
}