nb->blocks[i] = nb->blocks_data + i*nb->max_nr_squares;
#ifdef STANDALONE_SOLVER
- nb->blocknames = (char **)smalloc(b->c * b->r *(sizeof(char *)+80));
memcpy(nb->blocknames, b->blocknames, b->c * b->r *(sizeof(char *)+80));
{
int i;
usage->cube = snewn(cr*cr*cr, unsigned char);
usage->grid = grid; /* write straight back to the input */
if (kgrid) {
- int nclues = kblocks->nr_blocks;
+ int nclues;
+
+ assert(kblocks);
+ nclues = kblocks->nr_blocks;
/*
* Allow for expansion of the killer regions, the absolute
* limit is obviously one region per square.
"one solution");
#endif
+ sfree(usage->sq2region);
+ sfree(usage->regions);
sfree(usage->cube);
sfree(usage->row);
sfree(usage->col);
free_block_structure(usage->extra_cages);
sfree(usage->extra_clues);
}
+ if (usage->kclues) sfree(usage->kclues);
sfree(usage);
solver_free_scratch(scratch);
blocks = alloc_block_structure (c, r, area, cr, cr);
- if (params->killer) {
- kblocks = alloc_block_structure (c, r, area, cr, area);
- kgrid = snewn(area, digit);
- } else {
- kblocks = NULL;
- kgrid = NULL;
- }
+ kblocks = NULL;
+ kgrid = (params->killer) ? snewn(area, digit) : NULL;
#ifdef STANDALONE_SOLVER
assert(!"This should never happen, so we don't need to create blocknames");
make_blocks_from_whichblock(blocks);
if (params->killer) {
+ if (kblocks) free_block_structure(kblocks);
kblocks = gen_killer_cages(cr, rs, params->kdiff > DIFF_KSINGLE);
}
desc = encode_puzzle_desc(params, grid, blocks, kgrid, kblocks);
sfree(grid);
+ free_block_structure(blocks);
+ if (params->killer) {
+ free_block_structure(kblocks);
+ sfree(kgrid);
+ }
return desc;
}
sfree(state->immutable);
sfree(state->pencil);
sfree(state->grid);
+ if (state->kgrid) sfree(state->kgrid);
sfree(state);
}
((button >= '0' && button <= '9' && button - '0' <= cr) ||
(button >= 'a' && button <= 'z' && button - 'a' + 10 <= cr) ||
(button >= 'A' && button <= 'Z' && button - 'A' + 10 <= cr) ||
- button == CURSOR_SELECT2 || button == '\010' || button == '\177')) {
+ button == CURSOR_SELECT2 || button == '\b')) {
int n = button - '0';
if (button >= 'A' && button <= 'Z')
n = button - 'A' + 10;
if (button >= 'a' && button <= 'z')
n = button - 'a' + 10;
- if (button == CURSOR_SELECT2 || button == '\010' || button == '\177')
+ if (button == CURSOR_SELECT2 || button == '\b')
n = 0;
/*