Commit 7ae0a995 authored by Cory Quammen's avatar Cory Quammen

Fixed memory leak when multiple time steps read from file

A double array was allocated to store time steps but never freed.
Changed to a std::vector<double> that handles deallocation when it
goes out of scope.
parent f237e892
......@@ -46,6 +46,7 @@
#include <functional>
#include <locale> // C++ locale
#include <sstream>
#include <vector>
#include <sys/stat.h>
vtkCxxSetObjectMacro(vtkXMLReader,ReaderErrorObserver,vtkCommand);
......@@ -499,14 +500,14 @@ int vtkXMLReader::RequestInformation(vtkInformation *request,
this->TimeStepRange[1] = (numTimesteps > 0 ? numTimesteps-1 : 0);
if (numTimesteps != 0)
{
double* timeSteps = new double[numTimesteps];
for (int i = 0; i<numTimesteps; i++)
std::vector<double> timeSteps(numTimesteps);
for (int i = 0; i < numTimesteps; i++)
{
timeSteps[i] = i;
}
vtkInformation* outInfo = outputVector->GetInformationObject(0);
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
timeSteps,
&timeSteps[0],
numTimesteps);
double timeRange[2];
timeRange[0] = timeSteps[0];
......
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