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
112c9697
Commit
112c9697
authored
Mar 21, 2019
by
Uwe Schulzweida
Browse files
zaxisCreate/gridCreate: added check for size != 0.
parent
73a06838
Changes
3
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
112c9697
...
...
@@ -4,7 +4,7 @@
2019-03-21 Uwe Schulzweida
* zaxis
DefLevels: check number of levels
* zaxis
Create/gridCreate: added check for size != 0
2019-03-15 Uwe Schulzweida
...
...
src/grid.c
View file @
112c9697
...
...
@@ -534,6 +534,7 @@ int gridCreate(int gridtype, size_t size)
{
if
(
CDI_Debug
)
Message
(
"gridtype=%s size=%zu"
,
gridNamePtr
(
gridtype
),
size
);
xassert
(
size
);
gridInit
();
grid_t
*
gridptr
=
gridNewEntry
(
CDI_UNDEFID
);
...
...
@@ -1813,8 +1814,8 @@ static
void
gridDefYValsSerial
(
grid_t
*
gridptr
,
const
double
*
yvals
)
{
const
int
gridtype
=
gridptr
->
type
;
size_t
size
=
(
gridtype
==
GRID_CURVILINEAR
||
gridtype
==
GRID_UNSTRUCTURED
)
?
gridptr
->
size
:
gridptr
->
y
.
size
;
const
size_t
size
=
(
gridtype
==
GRID_CURVILINEAR
||
gridtype
==
GRID_UNSTRUCTURED
)
?
gridptr
->
size
:
gridptr
->
y
.
size
;
if
(
size
==
0
)
Error
(
"Size undefined for gridID = %d!"
,
gridptr
->
self
);
...
...
@@ -3084,19 +3085,19 @@ static void
gridDefBoundsGeneric
(
grid_t
*
gridptr
,
const
double
*
bounds
,
size_t
regularSize
,
double
**
field
)
{
int
irregular
=
gridptr
->
type
==
GRID_CURVILINEAR
||
gridptr
->
type
==
GRID_UNSTRUCTURED
;
size_t
nvertex
=
(
size_t
)
gridptr
->
nvertex
;
const
int
irregular
=
gridptr
->
type
==
GRID_CURVILINEAR
||
gridptr
->
type
==
GRID_UNSTRUCTURED
;
const
size_t
nvertex
=
(
size_t
)
gridptr
->
nvertex
;
if
(
nvertex
==
0
)
{
Warning
(
"nvertex undefined for gridID = %d. Cannot define bounds!"
,
gridptr
->
self
);
return
;
}
size_t
size
=
nvertex
*
(
irregular
?
gridptr
->
size
:
regularSize
);
const
size_t
size
=
nvertex
*
(
irregular
?
gridptr
->
size
:
regularSize
);
if
(
size
==
0
)
Error
(
"size undefined for gridID = %d"
,
gridptr
->
self
);
if
(
*
field
==
NULL
)
if
(
*
field
==
NULL
&&
size
)
*
field
=
(
double
*
)
Malloc
(
size
*
sizeof
(
double
));
else
if
(
CDI_Debug
)
Warning
(
"values already defined!"
);
...
...
src/zaxis.c
View file @
112c9697
...
...
@@ -818,9 +818,11 @@ The function @func{zaxisDefLevel} defines one level of a Z-axis.
void
zaxisDefLevel
(
int
zaxisID
,
int
levelID
,
double
level
)
{
zaxis_t
*
zaxisptr
=
zaxis_to_pointer
(
zaxisID
);
int
size
=
zaxisptr
->
size
;
const
int
size
=
zaxisptr
->
size
;
xassert
(
size
);
xassert
(
levelID
>=
0
&&
levelID
<
size
);
if
(
zaxisptr
->
vals
==
NULL
)
if
(
zaxisptr
->
vals
==
NULL
&&
size
)
zaxisptr
->
vals
=
(
double
*
)
Malloc
((
size_t
)
size
*
sizeof
(
double
));
if
(
levelID
>=
0
&&
levelID
<
size
)
...
...
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