Commit dd71d42a authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

define_all_vars: Release memory of not freed attributes

parent 0673a350
...@@ -6000,7 +6000,7 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva ...@@ -6000,7 +6000,7 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
/* define all input data variables */ /* define all input data variables */
static static
void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID, int *varids, int nvars, ncvar_t *ncvars) void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID, int *varids, int nvars, int num_ncvars, ncvar_t *ncvars)
{ {
int ncid; int ncid;
int varID1, varID, ncvarid; int varID1, varID, ncvarid;
...@@ -6207,9 +6207,14 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID, ...@@ -6207,9 +6207,14 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
} }
free(ncvars[ncvarid].atts); free(ncvars[ncvarid].atts);
ncvars[ncvarid].atts = NULL;
} }
} }
/* release mem of not freed attributes */
for ( ncvarid = 0; ncvarid < num_ncvars; ncvarid++ )
if ( ncvars[ncvarid].atts ) free(ncvars[ncvarid].atts);
if ( varids ) free(varids); if ( varids ) free(varids);
for ( varID = 0; varID < nvars; varID++ ) for ( varID = 0; varID < nvars; varID++ )
...@@ -6813,7 +6818,7 @@ int cdfInqContents(stream_t *streamptr) ...@@ -6813,7 +6818,7 @@ int cdfInqContents(stream_t *streamptr)
streamptr->ntsteps = ntsteps; streamptr->ntsteps = ntsteps;
/* define all data variables */ /* define all data variables */
define_all_vars(streamptr, vlistID, instID, modelID, varids, nvars_data, ncvars); define_all_vars(streamptr, vlistID, instID, modelID, varids, nvars_data, nvars, ncvars);
cdiCreateTimesteps(streamptr); cdiCreateTimesteps(streamptr);
...@@ -6911,10 +6916,10 @@ int cdfInqContents(stream_t *streamptr) ...@@ -6911,10 +6916,10 @@ int cdfInqContents(stream_t *streamptr)
cdfCreateRecords(streamptr, 0); cdfCreateRecords(streamptr, 0);
/* free ncdims */ /* free ncdims */
free (ncdims); free(ncdims);
/* free ncvars */ /* free ncvars */
free (ncvars); free(ncvars);
#endif #endif
......
Supports Markdown
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