Commit 308d84cc authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

vlistCat: set varsAllocated to nvars

parent 228586f1
......@@ -372,6 +372,7 @@ void vlistCopy(int vlistID2, int vlistID1)
int nvars = vlistptr1->nvars;
int nlevs, varID;
//vlistptr2->varsAllocated = nvars;
vlistptr2->vars = (var_t *) malloc(vlistptr2->varsAllocated*sizeof(var_t));
memcpy(vlistptr2->vars, vlistptr1->vars, vlistptr2->varsAllocated*sizeof(var_t));
......@@ -725,7 +726,11 @@ void vlistCat(int vlistID2, int vlistID1)
nvars = nvars1 + nvars2;
vlistptr2->nvars = nvars;
vlistptr2->vars = (var_t *) realloc(vlistptr2->vars, nvars*sizeof(var_t));
if ( nvars > vlistptr2->varsAllocated )
{
vlistptr2->varsAllocated = nvars;
vlistptr2->vars = (var_t *) realloc(vlistptr2->vars, nvars*sizeof(var_t));
}
memcpy(vlistptr2->vars+nvars2, vlistptr1->vars, nvars1*sizeof(var_t));
for ( varID = 0; varID < nvars1; varID++ )
......
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