Skip to content
GitLab
Menu
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
1fc2bfc1
Commit
1fc2bfc1
authored
Apr 07, 2016
by
Thomas Jahns
🤸
Browse files
Prevent duplication of string copy.
parent
00c30f22
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf.c
View file @
1fc2bfc1
...
...
@@ -3396,7 +3396,6 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
#if defined (HAVE_NETCDF4)
if
(
format
==
NC_FORMAT_NETCDF4_CLASSIC
||
format
==
NC_FORMAT_NETCDF4
)
{
char
buf
[
CDI_MAX_NAME
];
int
shuffle
,
deflate
,
deflate_level
;
size_t
chunks
[
nvdims
];
int
storage_in
;
...
...
@@ -3415,14 +3414,19 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
for
(
int
i
=
0
;
i
<
nvdims
;
++
i
)
fprintf
(
stderr
,
"%ld "
,
chunks
[
i
]);
fprintf
(
stderr
,
"
\n
"
);
}
strcat
(
ncvars
[
ncvarid
].
extra
,
"chunks="
);
for
(
int
i
=
nvdims
-
1
;
i
>=
0
;
--
i
)
{
sprintf
(
buf
,
"%ld"
,
(
long
)
chunks
[
i
]);
strcat
(
ncvars
[
ncvarid
].
extra
,
buf
);
if
(
i
>
0
)
strcat
(
ncvars
[
ncvarid
].
extra
,
"x"
);
}
strcat
(
ncvars
[
ncvarid
].
extra
,
" "
);
{
char
*
buf
=
ncvars
[
ncvarid
].
extra
;
size_t
pos
=
strlen
(
buf
);
static
const
char
prefix
[]
=
"chunks="
;
memcpy
(
buf
+
pos
,
prefix
,
sizeof
(
prefix
));
pos
+=
sizeof
(
prefix
)
-
1
;
for
(
int
i
=
nvdims
-
1
;
i
>=
0
;
--
i
)
{
pos
+=
(
size_t
)(
sprintf
(
buf
+
pos
,
"%zu%s"
,
chunks
[
i
],
i
>
0
?
"x"
:
""
));
}
buf
[
pos
]
=
' '
;
buf
[
pos
+
1
]
=
0
;
}
}
}
}
...
...
Write
Preview
Supports
Markdown
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