Skip to content
Snippets Groups Projects
Commit bdf10774 authored by Franck Dary's avatar Franck Dary
Browse files

Corrected a memory leak

parent 7438dcd3
No related branches found
No related tags found
No related merge requests found
...@@ -617,6 +617,21 @@ void Config::printColumnInfos(unsigned int index) ...@@ -617,6 +617,21 @@ void Config::printColumnInfos(unsigned int index)
void Config::addToActionsHistory(std::string & state, const std::string & action, int cost) void Config::addToActionsHistory(std::string & state, const std::string & action, int cost)
{ {
if (actionsHistory.size() > 2000)
for (auto it = actionsHistory.cbegin(); it != actionsHistory.cend();)
{
try
{
if (std::stoi(split(it->first, '_').back()) < head-20)
{
it = actionsHistory.erase(it);
continue;
}
} catch (std::exception &) {fprintf(stderr, "ERROR (%s) : calling std::stoi on \'%s\'.aborting.\n", ERRINFO, split(it->first, '_').back().c_str()); exit(1);}
it++;
}
actionsHistory[state+"_"+std::to_string(head)].emplace_back(action, cost); actionsHistory[state+"_"+std::to_string(head)].emplace_back(action, cost);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment