Commit 79cf0ffb authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gridInqXCvalsSerial: bug fix.

parent 33e71c37
......@@ -1550,19 +1550,17 @@ int gridInqXCvalsSerial(grid_t *gridptr, char **xcvals)
Error("Function only valid for grid type 'GRID_CHARXY'.");
int size = gridptr->x.size;
const char **gridptr_xcvals = gridptr->vtable->inqXCvalsPtr(gridptr);
if ( size == 0 || !gridptr_xcvals )
Error("No string coordinates found!");
int stringlen = strlen(gridptr_xcvals[0]);
if ( stringlen == 0 )
Error("Length of string coordinates not defined.");
int maxclength = 0;
if ( xcvals )
for ( int i = 0; i < size; i++ )
memcpy(xcvals[i], gridptr_xcvals[i], (size_t)stringlen * sizeof(char));
const char **gridptr_xcvals = gridptr->vtable->inqXCvalsPtr(gridptr);
if ( gridptr_xcvals && size && xcvals )
{
maxclength = gridptr->x.clength;
for ( int i = 0; i < size; i++ )
memcpy(xcvals[i], gridptr_xcvals[i], (size_t)maxclength*sizeof(char));
}
return (int)stringlen;
return maxclength;
}
static
......@@ -1646,21 +1644,17 @@ int gridInqYCvalsSerial(grid_t *gridptr, char **ycvals)
Error("Function only valid for grid type 'GRID_CHARXY'.");
int size = gridptr->y.size;
int stringlen = 0;
int maxclength = 0;
if ( gridptr->y.cvals )
const char **gridptr_ycvals = gridptr->vtable->inqYCvalsPtr(gridptr);
if ( gridptr_ycvals && size && ycvals )
{
if ( size && ycvals )
{
const char **gridptr_ycvals = gridptr->vtable->inqYCvalsPtr(gridptr);
stringlen = strlen(gridptr_ycvals[0]);
memcpy(ycvals, gridptr_ycvals, (size_t)size * sizeof ( (size_t)stringlen * sizeof(char)));
}
maxclength = gridptr->y.clength;
for ( int i = 0; i < size; i++ )
memcpy(ycvals[i], gridptr_ycvals[i], (size_t)maxclength*sizeof(char));
}
else
size = 0;
return (int)stringlen;
return maxclength;
}
static
......
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