Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
a2b3e0b8
Commit
a2b3e0b8
authored
Jan 07, 2015
by
Uwe Schulzweida
Browse files
cdfGetAttInt: convert to double only if attr type is not equal NC_CHAR
parent
851b2bc8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf.c
View file @
a2b3e0b8
...
...
@@ -360,22 +360,30 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
static
void
cdfGetAttInt
(
int
fileID
,
int
ncvarid
,
char
*
attname
,
int
attlen
,
int
*
attint
)
{
nc_type
atttype
;
size_t
nc_attlen
;
int
*
pintatt
;
*
attint
=
0
;
cdf_inq_atttype
(
fileID
,
ncvarid
,
attname
,
&
atttype
);
cdf_inq_attlen
(
fileID
,
ncvarid
,
attname
,
&
nc_attlen
);
if
(
(
int
)
nc_attlen
>
attlen
)
pintatt
=
(
int
*
)
malloc
(
nc_attlen
*
sizeof
(
int
));
else
pintatt
=
attint
;
if
(
atttype
!=
NC_CHAR
)
{
int
*
pintatt
=
NULL
;
if
(
(
int
)
nc_attlen
>
attlen
)
pintatt
=
(
int
*
)
malloc
(
nc_attlen
*
sizeof
(
int
));
else
pintatt
=
attint
;
cdf_get_att_int
(
fileID
,
ncvarid
,
attname
,
pintatt
);
cdf_get_att_int
(
fileID
,
ncvarid
,
attname
,
pintatt
);
if
(
(
int
)
nc_attlen
>
attlen
)
{
memcpy
(
attint
,
pintatt
,
(
size_t
)
attlen
*
sizeof
(
int
));
free
(
pintatt
);
if
(
(
int
)
nc_attlen
>
attlen
)
{
memcpy
(
attint
,
pintatt
,
(
size_t
)
attlen
*
sizeof
(
int
));
free
(
pintatt
);
}
}
}
...
...
@@ -383,7 +391,7 @@ static
void
cdfGetAttDouble
(
int
fileID
,
int
ncvarid
,
char
*
attname
,
int
attlen
,
double
*
attdouble
)
{
nc_type
atttype
;
size_t
nc_attlen
=
0
;
size_t
nc_attlen
;
*
attdouble
=
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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