Improve Game and HalfMoves memory management

This commit is contained in:
Loic Guegan 2022-02-28 19:13:27 +01:00
parent a8c59c41bc
commit 4c959fe12e
6 changed files with 19 additions and 3 deletions
src/game_tab

View file

@ -15,13 +15,19 @@ Game::Game(std::string fen) : current(NULL), moves(NULL), result("*") {
board = chessarbiter::FENParser::Parse(fen).board;
}
Game::Game(HalfMove *m, std::string initial_fen): result("*") {
Game::Game(HalfMove *m, std::string initial_fen) : result("*") {
moves = m;
current = m;
this->initial_fen = initial_fen;
board = chessarbiter::FENParser::Parse(initial_fen).board;
}
Game::~Game() {
if (moves != NULL) {
delete moves;
}
}
std::string Game::GetBoard() { return (board); }
std::string Game::GetTag(std::string tagname) { return (tags[tagname]); }