Commit 851b2bc8 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdfGetAttDouble: convert to double only if attr type is not equal NC_CHAR

parent 612ddbfa
...@@ -382,22 +382,30 @@ void cdfGetAttInt(int fileID, int ncvarid, char *attname, int attlen, int *attin ...@@ -382,22 +382,30 @@ void cdfGetAttInt(int fileID, int ncvarid, char *attname, int attlen, int *attin
static static
void cdfGetAttDouble(int fileID, int ncvarid, char *attname, int attlen, double *attdouble) void cdfGetAttDouble(int fileID, int ncvarid, char *attname, int attlen, double *attdouble)
{ {
size_t nc_attlen; nc_type atttype;
double *pdoubleatt; size_t nc_attlen = 0;
*attdouble = 0;
cdf_inq_atttype(fileID, ncvarid, attname, &atttype);
cdf_inq_attlen(fileID, ncvarid, attname, &nc_attlen); cdf_inq_attlen(fileID, ncvarid, attname, &nc_attlen);
if ( (int)nc_attlen > attlen ) if ( atttype != NC_CHAR )
pdoubleatt = (double *) malloc(nc_attlen * sizeof (double)); {
else double *pdoubleatt = NULL;
pdoubleatt = attdouble;
cdf_get_att_double(fileID, ncvarid, attname, pdoubleatt); if ( (int)nc_attlen > attlen )
pdoubleatt = (double *) malloc(nc_attlen * sizeof (double));
else
pdoubleatt = attdouble;
if ( (int)nc_attlen > attlen ) cdf_get_att_double(fileID, ncvarid, attname, pdoubleatt);
{
memcpy(attdouble, pdoubleatt, (size_t)attlen * sizeof (double)); if ( (int)nc_attlen > attlen )
free(pdoubleatt); {
memcpy(attdouble, pdoubleatt, (size_t)attlen * sizeof (double));
free(pdoubleatt);
}
} }
} }
......
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