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
123d4138
Commit
123d4138
authored
May 22, 2017
by
Fabian Wachsmann
Browse files
Replaced strcpy by memcpy and added Free for char arrays
parent
b7dea9bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf_i.c
View file @
123d4138
...
...
@@ -2881,8 +2881,8 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if
(
ncvars
[
zvarid
].
ndims
==
2
)
{
zprec
=
CDI_DATATYPE_UINT8
;
zclength
=
ncdims
[
ncvars
[
zvarid
].
dimids
[
1
]].
len
;
cdf_load_cvals
(
zsize
*
zclength
,
zvarid
,
ncvar
,
&
zcvals
,
zsize
);
zclength
=
(
size_t
)
ncdims
[
ncvars
[
zvarid
].
dimids
[
1
]].
len
;
cdf_load_cvals
(
zsize
*
zclength
,
zvarid
,
ncvar
,
&
zcvals
,
(
size_t
)
zsize
);
}
}
...
...
@@ -2980,6 +2980,12 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
cdiZaxisDefKeyStr(zaxisID, CDI_KEY_VDIMNAME, strlen(ncdims[vdimid].name)+1, ncdims[vdimid].name);
*/
if
(
zvar
)
Free
(
zvar
);
if
(
zcvals
)
{
for
(
size_t
i
=
0
;
i
<
zsize
;
i
++
)
Free
(
zcvals
[
i
]);
Free
(
zcvals
);
}
if
(
lbounds
)
Free
(
lbounds
);
if
(
zvarid
!=
CDI_UNDEFID
)
...
...
src/zaxis.c
View file @
123d4138
...
...
@@ -274,7 +274,12 @@ void zaxisDestroyKernel( zaxis_t * zaxisptr )
int
id
=
zaxisptr
->
self
;
if
(
zaxisptr
->
vals
)
Free
(
zaxisptr
->
vals
);
if
(
zaxisptr
->
cvals
)
Free
(
zaxisptr
->
cvals
);
if
(
zaxisptr
->
cvals
)
{
for
(
int
i
=
0
;
i
<
zaxisptr
->
size
;
i
++
)
Free
(
zaxisptr
->
cvals
[
i
]);
Free
(
zaxisptr
->
cvals
);
}
if
(
zaxisptr
->
lbounds
)
Free
(
zaxisptr
->
lbounds
);
if
(
zaxisptr
->
ubounds
)
Free
(
zaxisptr
->
ubounds
);
if
(
zaxisptr
->
weights
)
Free
(
zaxisptr
->
weights
);
...
...
@@ -793,7 +798,7 @@ void zaxisDefCvals(int zaxisID, const char **cvals, size_t clen)
for
(
size_t
ilev
=
0
;
ilev
<
size
;
++
ilev
)
{
zaxisptr
->
cvals
[
ilev
]
=
Malloc
((
clen
+
1
)
*
sizeof
(
char
));
str
cpy
(
zaxisptr
->
cvals
[
ilev
],
cvals
[
ilev
]);
mem
cpy
(
zaxisptr
->
cvals
[
ilev
],
cvals
[
ilev
]
,
clen
);
zaxisptr
->
cvals
[
ilev
][
clen
]
=
'\0'
;
}
reshSetStatus
(
zaxisID
,
&
zaxisOps
,
RESH_DESYNC_IN_USE
);
...
...
@@ -1061,8 +1066,9 @@ int zaxisInqCLevels(int zaxisID, char ***clevels)
(
*
clevels
)
=
Malloc
(
size
*
sizeof
(
char
*
));
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
(
*
clevels
)[
i
]
=
Malloc
(
clen
*
sizeof
(
char
));
strcpy
((
*
clevels
)[
i
],
zaxisptr
->
cvals
[
i
]);
(
*
clevels
)[
i
]
=
Malloc
((
clen
+
1
)
*
sizeof
(
char
));
memcpy
((
*
clevels
)[
i
],
zaxisptr
->
cvals
[
i
],
clen
);
(
*
clevels
)[
i
][
clen
]
=
'\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