Implement support for board preallocation
This commit is contained in:
parent
c7730e0c84
commit
0e4506cd52
5
board.c
5
board.c
@ -597,6 +597,7 @@ board_place (
|
|||||||
struct board *
|
struct board *
|
||||||
board_place_speculative (
|
board_place_speculative (
|
||||||
const struct board *board,
|
const struct board *board,
|
||||||
|
struct board *board_duplicate,
|
||||||
board_pos x,
|
board_pos x,
|
||||||
board_pos y,
|
board_pos y,
|
||||||
element_value value
|
element_value value
|
||||||
@ -608,14 +609,10 @@ board_place_speculative (
|
|||||||
if (board_can_place_value (board, x, y, value))
|
if (board_can_place_value (board, x, y, value))
|
||||||
{
|
{
|
||||||
/* Create duplicate and place value */
|
/* Create duplicate and place value */
|
||||||
struct board *board_duplicate = malloc (sizeof (struct board));
|
|
||||||
board_copy (board, board_duplicate);
|
board_copy (board, board_duplicate);
|
||||||
|
|
||||||
if (! board_place (board_duplicate, x, y, value))
|
if (! board_place (board_duplicate, x, y, value))
|
||||||
{
|
|
||||||
free (board_duplicate);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
return board_duplicate;
|
return board_duplicate;
|
||||||
}
|
}
|
||||||
|
1
board.h
1
board.h
@ -261,6 +261,7 @@ board_place (
|
|||||||
struct board *
|
struct board *
|
||||||
board_place_speculative (
|
board_place_speculative (
|
||||||
const struct board *board,
|
const struct board *board,
|
||||||
|
struct board *board_duplicate,
|
||||||
board_pos x,
|
board_pos x,
|
||||||
board_pos y,
|
board_pos y,
|
||||||
element_value value
|
element_value value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user