Commit b670651a authored by VAN TOLL Wouter's avatar VAN TOLL Wouter

CostFunctionFactory: Fixed a small memory leak.

parent 86e92847
......@@ -58,4 +58,9 @@ void CostFunctionFactory::RegisterAllCostFunctions()
registerCostFunction<Paris>();
registerCostFunction<PLEdestrians>();
registerCostFunction<VanToll>();
}
void CostFunctionFactory::ClearRegistry()
{
registry.clear();
}
\ No newline at end of file
......@@ -57,6 +57,10 @@ public:
/// Call this method once before you start using CreateCostFunction().</summary>
static void RegisterAllCostFunctions();
/// <summary>Clears the list of registered cost functions.
/// Call this method when you destroy the Simulator.</summary>
static void ClearRegistry();
/// <summary>Creates and returns a new CostFunction instance whose name matches the given value.</summary>
/// <remarks>This method looks through the registry created in RegisterAllCostFunctions().</remarks>
/// <param name="name">The name of the cost function to create.</param>
......
......@@ -49,7 +49,7 @@ bool CostFunctionParameters::ReadString(const std::string &name, std::string &va
if (str != nullptr)
{
value = std::string(str);
// delete[] str; //???
delete[] str;
return true;
}
return false;
......
......@@ -69,6 +69,9 @@ CrowdSimulator::~CrowdSimulator()
for (auto& policy : policies_)
delete policy.second;
policies_.clear();
// clear all cost-function creation functions
CostFunctionFactory::ClearRegistry();
}
void CrowdSimulator::RunSimulationSteps(int nrSteps)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment