]> git.sesse.net Git - stockfish/commitdiff
Detach the state when copying a position
authorMarco Costalba <mcostalba@gmail.com>
Fri, 29 May 2009 15:23:21 +0000 (17:23 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 29 May 2009 15:23:21 +0000 (17:23 +0200)
In Position we store a pointer to a StateInfo record
kept outside of the Position object.

When copying a position we copy also that pointer so
after the copy we have two Position objects pointing
to the same StateInfo record. This can be dangerous
so fix by copying also the StateInfo record inside
the new Position object and let the new st pointer
point to it. This completely detach the copied
Position from the original one.

Also rename setStartState() as saveState() and clean up
the API to state more clearly what the function does.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>

No differences found