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
a35ab86a
Commit
a35ab86a
authored
Jun 02, 2019
by
Uwe Schulzweida
Browse files
cgribexDecode: allocate cgribexp if needed.
parent
69001163
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/grb_read.c
View file @
a35ab86a
...
...
@@ -135,6 +135,7 @@ DecodeArgs grb_read_raw_data(stream_t *streamptr, int recID, int memtype, void *
if
(
recsize
==
0
)
Error
(
"Internal problem! Recordsize is zero for record %d at timestep %d"
,
recID
+
1
,
tsID
+
1
);
void
*
cgribexp
=
(
gribbuffer
&&
streamptr
->
record
->
cgribexp
)
?
streamptr
->
record
->
cgribexp
:
NULL
;
if
(
!
gribbuffer
)
gribbuffer
=
Malloc
(
streamptr
->
record
->
buffersize
);
if
(
!
data
)
data
=
Malloc
(
gridsize
*
(
memtype
==
MEMTYPE_FLOAT
?
sizeof
(
float
)
:
sizeof
(
double
)));
...
...
@@ -157,7 +158,7 @@ DecodeArgs grb_read_raw_data(stream_t *streamptr, int recID, int memtype, void *
.
outZip
=
&
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
zip
,
.
filetype
=
streamptr
->
filetype
,
.
memtype
=
memtype
,
.
cgribexp
=
streamptr
->
record
->
cgribexp
,
.
cgribexp
=
cgribexp
,
.
gribbuffer
=
gribbuffer
,
.
recsize
=
recsize
,
.
data
=
data
,
...
...
src/stream_cgribex.c
View file @
a35ab86a
...
...
@@ -1297,7 +1297,8 @@ int cgribexDecode(int memtype, void *cgribex, void *gribbuffer, size_t gribsize,
{
int
status
=
0
;
cgribexrec_t
*
cgribexp
=
(
cgribexrec_t
*
)
cgribex
;
bool
lalloc
=
cgribex
==
NULL
;
cgribexrec_t
*
cgribexp
=
(
cgribexrec_t
*
)
(
lalloc
?
cgribexNew
()
:
cgribex
);
int
*
isec0
=
cgribexp
->
sec0
;
int
*
isec1
=
cgribexp
->
sec1
;
...
...
@@ -1352,6 +1353,8 @@ int cgribexDecode(int memtype, void *cgribex, void *gribbuffer, size_t gribsize,
}
}
if
(
lalloc
)
cgribexDelete
(
cgribexp
);
return
status
;
}
...
...
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