Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
851b2bc8
Commit
851b2bc8
authored
Jan 07, 2015
by
Uwe Schulzweida
Browse files
cdfGetAttDouble: convert to double only if attr type is not equal NC_CHAR
parent
612ddbfa
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf.c
View file @
851b2bc8
...
...
@@ -382,22 +382,30 @@ void cdfGetAttInt(int fileID, int ncvarid, char *attname, int attlen, int *attin
static
void
cdfGetAttDouble
(
int
fileID
,
int
ncvarid
,
char
*
attname
,
int
attlen
,
double
*
attdouble
)
{
size_t
nc_attlen
;
double
*
pdoubleatt
;
nc_type
atttype
;
size_t
nc_attlen
=
0
;
*
attdouble
=
0
;
cdf_inq_atttype
(
fileID
,
ncvarid
,
attname
,
&
atttype
);
cdf_inq_attlen
(
fileID
,
ncvarid
,
attname
,
&
nc_attlen
);
if
(
(
int
)
nc_attlen
>
attlen
)
pdoubleatt
=
(
double
*
)
malloc
(
nc_attlen
*
sizeof
(
double
));
else
pdoubleatt
=
attdouble
;
if
(
atttype
!=
NC_CHAR
)
{
double
*
pdoubleatt
=
NULL
;
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
)
{
memcpy
(
attdouble
,
pdoubleatt
,
(
size_t
)
attlen
*
sizeof
(
double
));
free
(
pdoubleatt
);
cdf_get_att_double
(
fileID
,
ncvarid
,
attname
,
pdoubleatt
);
if
(
(
int
)
nc_attlen
>
attlen
)
{
memcpy
(
attdouble
,
pdoubleatt
,
(
size_t
)
attlen
*
sizeof
(
double
));
free
(
pdoubleatt
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment