Skip to content
Snippets Groups Projects
Commit 306d26e9 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replaced Malloc() by std::vector.

parent 214e2c27
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,6 @@ Mergetime(void *process)
int64_t last_vdate = -1;
int last_vtime = -1;
bool skip_same_time = false;
double *array = NULL;
struct sfile_t
{
int streamID;
......@@ -63,8 +62,7 @@ Mergetime(void *process)
bool lcopy = UNCHANGED_RECORD;
int nfiles = cdoStreamCnt() - 1;
sfile_t *sf = (sfile_t *) Malloc(nfiles * sizeof(sfile_t));
std::vector<sfile_t> sf(nfiles);
for (int fileID = 0; fileID < nfiles; fileID++)
{
......@@ -102,10 +100,11 @@ Mergetime(void *process)
int streamID2 = cdoStreamOpenWrite(cdoStreamName(nfiles), cdoFiletype());
std::vector<double> array;
if (!lcopy)
{
size_t gridsize = vlistGridsizeMax(sf[0].vlistID);
array = (double *) Malloc(gridsize * sizeof(double));
size_t gridsizemax = vlistGridsizeMax(sf[0].vlistID);
array.resize(gridsizemax);
}
while (true)
......@@ -180,8 +179,8 @@ Mergetime(void *process)
else
{
size_t nmiss;
pstreamReadRecord(sf[fileID].streamID, array, &nmiss);
pstreamWriteRecord(streamID2, array, nmiss);
pstreamReadRecord(sf[fileID].streamID, array.data(), &nmiss);
pstreamWriteRecord(streamID2, array.data(), nmiss);
}
}
......@@ -203,11 +202,6 @@ Mergetime(void *process)
pstreamClose(streamID2);
if (!lcopy)
if (array) Free(array);
if (sf) Free(sf);
cdoFinish();
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment