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
2da6059b
Commit
2da6059b
authored
Aug 28, 2015
by
Oliver Heidmann
Browse files
replaced all xmalloc with malloc
parent
24516c6b
Changes
39
Hide whitespace changes
Inline
Side-by-side
src/file.c
View file @
2da6059b
...
...
@@ -190,7 +190,7 @@ void file_list_new(void)
{
assert
(
_fileList
==
NULL
);
_fileList
=
(
filePtrToIdx
*
)
x
malloc
((
size_t
)
_file_max
*
sizeof
(
filePtrToIdx
));
_fileList
=
(
filePtrToIdx
*
)
malloc
((
size_t
)
_file_max
*
sizeof
(
filePtrToIdx
));
}
static
...
...
src/gribapi.c
View file @
2da6059b
...
...
@@ -88,7 +88,7 @@ void gribContainersNew(stream_t * streamptr)
streamptr
->
gribContainers
=
(
void
**
)
gribContainers
;
#else
gribContainer_t
*
gribContainers
=
(
gribContainer_t
*
)
x
malloc
((
size_t
)
nvars
*
sizeof
(
gribContainer_t
));
=
(
gribContainer_t
*
)
malloc
((
size_t
)
nvars
*
sizeof
(
gribContainer_t
));
for
(
int
varID
=
0
;
varID
<
nvars
;
++
varID
)
{
...
...
src/gribapi_utilities.c
View file @
2da6059b
...
...
@@ -32,7 +32,7 @@ char* gribCopyString(grib_handle* gribHandle, const char* key)
#ifdef HAVE_GRIB_GET_LENGTH
if
(
!
grib_get_length
(
gribHandle
,
key
,
&
length
))
{
char
*
result
=
(
char
*
)
x
malloc
(
length
);
char
*
result
=
(
char
*
)
malloc
(
length
);
if
(
!
grib_get_string
(
gribHandle
,
key
,
result
,
&
length
))
result
=
(
char
*
)
xrealloc
(
result
,
length
);
...
...
@@ -48,7 +48,7 @@ char* gribCopyString(grib_handle* gribHandle, const char* key)
* this unlikely in grib_api versions
* not providing grib_get_length */
int
rc
;
result
=
(
char
*
)
x
malloc
(
length
);
result
=
(
char
*
)
malloc
(
length
);
while
((
rc
=
grib_get_string
(
gribHandle
,
key
,
result
,
&
length
))
==
GRIB_BUFFER_TOO_SMALL
||
rc
==
GRIB_ARRAY_TOO_SMALL
)
{
...
...
@@ -80,7 +80,7 @@ bool gribCheckString(grib_handle* gribHandle, const char* key, const char* expec
size_t
length
;
if
(
grib_get_length
(
gribHandle
,
key
,
&
length
))
return
false
;
if
(
length
!=
expectedLength
)
return
false
;
char
*
value
=
(
char
*
)
x
malloc
(
length
);
char
*
value
=
(
char
*
)
malloc
(
length
);
if
(
grib_get_string
(
gribHandle
,
key
,
value
,
&
length
))
return
false
;
int
rc
=
!
strcmp
(
value
,
expectedValue
);
free
(
value
);
...
...
@@ -259,7 +259,7 @@ static int addToDate(struct tm* me, long long amount, long unit)
static
char
*
makeDateString
(
struct
tm
*
me
)
{
char
*
result
=
(
char
*
)
x
malloc
(
4
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
4
+
1
);
=
(
char
*
)
malloc
(
4
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
4
+
1
);
sprintf
(
result
,
"%04d-%02d-%02dT%02d:%02d:%02d.000"
,
me
->
tm_year
+
1900
,
me
->
tm_mon
+
1
,
me
->
tm_mday
,
me
->
tm_hour
,
me
->
tm_min
,
me
->
tm_sec
);
return
result
;
}
...
...
src/grid.c
View file @
2da6059b
...
...
@@ -169,7 +169,7 @@ void grid_free(grid_t *gridptr)
static
grid_t
*
gridNewEntry
(
cdiResH
resH
)
{
grid_t
*
gridptr
=
(
grid_t
*
)
x
malloc
(
sizeof
(
grid_t
));
grid_t
*
gridptr
=
(
grid_t
*
)
malloc
(
sizeof
(
grid_t
));
grid_init
(
gridptr
);
if
(
resH
==
CDI_UNDEFID
)
gridptr
->
self
=
reshPut
(
gridptr
,
&
gridOps
);
...
...
@@ -233,7 +233,7 @@ void gridGenXvals(int xsize, double xfirst, double xlast, double xinc, double *x
static
void
calc_gaussgrid
(
double
*
yvals
,
int
ysize
,
double
yfirst
,
double
ylast
)
{
double
*
restrict
yw
=
(
double
*
)
x
malloc
((
size_t
)
ysize
*
sizeof
(
double
));
double
*
restrict
yw
=
(
double
*
)
malloc
((
size_t
)
ysize
*
sizeof
(
double
));
gaussaw
(
yvals
,
yw
,
(
size_t
)
ysize
);
free
(
yw
);
for
(
int
i
=
0
;
i
<
ysize
;
i
++
)
...
...
@@ -273,7 +273,7 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
/* printf("%g %g %g %g %g %d\n", ylast, yfirst, ylast-yfirst,yinc, 180/yinc, ny); */
if
(
ny
>
ysize
&&
ny
<
4096
)
{
ytmp
=
(
double
*
)
x
malloc
((
size_t
)
ny
*
sizeof
(
double
));
ytmp
=
(
double
*
)
malloc
((
size_t
)
ny
*
sizeof
(
double
));
calc_gaussgrid
(
ytmp
,
ny
,
yfirst
,
ylast
);
int
i
;
for
(
i
=
0
;
i
<
(
ny
-
ysize
);
i
++
)
...
...
@@ -1214,7 +1214,7 @@ void gridDefRowlon(int gridID, int nrowlon, const int rowlon[])
{
grid_t
*
gridptr
=
gridID2Ptr
(
gridID
);
gridptr
->
rowlon
=
(
int
*
)
x
malloc
((
size_t
)
nrowlon
*
sizeof
(
int
));
gridptr
->
rowlon
=
(
int
*
)
malloc
((
size_t
)
nrowlon
*
sizeof
(
int
));
gridptr
->
nrowlon
=
nrowlon
;
memcpy
(
gridptr
->
rowlon
,
rowlon
,
(
size_t
)
nrowlon
*
sizeof
(
int
));
reshSetStatus
(
gridID
,
&
gridOps
,
RESH_DESYNC_IN_USE
);
...
...
@@ -1279,7 +1279,7 @@ void gridDefMask(int gridID, const int *mask)
else
{
if
(
gridptr
->
mask
==
NULL
)
gridptr
->
mask
=
(
mask_t
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
gridptr
->
mask
=
(
mask_t
*
)
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
else
if
(
CDI_Debug
)
Warning
(
"grid mask already defined!"
);
...
...
@@ -1318,7 +1318,7 @@ void gridDefMaskGME(int gridID, const int *mask)
Error
(
"Size undefined for gridID = %d"
,
gridID
);
if
(
gridptr
->
mask_gme
==
NULL
)
gridptr
->
mask_gme
=
(
mask_t
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
gridptr
->
mask_gme
=
(
mask_t
*
)
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
else
if
(
CDI_Debug
)
Warning
(
"mask already defined!"
);
...
...
@@ -2008,7 +2008,7 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
if
(
!
differ
&&
xsize
==
gridInqXvals
(
gridID
,
NULL
)
)
{
double
*
xvals
=
(
double
*
)
x
malloc
((
size_t
)
xsize
*
sizeof
(
double
));
double
*
xvals
=
(
double
*
)
malloc
((
size_t
)
xsize
*
sizeof
(
double
));
gridInqXvals
(
gridID
,
xvals
);
...
...
@@ -2024,7 +2024,7 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
if
(
!
differ
&&
ysize
==
gridInqYvals
(
gridID
,
NULL
)
)
{
double
*
yvals
=
(
double
*
)
x
malloc
((
size_t
)
ysize
*
sizeof
(
double
));
double
*
yvals
=
(
double
*
)
malloc
((
size_t
)
ysize
*
sizeof
(
double
));
gridInqYvals
(
gridID
,
yvals
);
...
...
@@ -2441,7 +2441,7 @@ int gridGenerate(const grid_t *grid)
else
if
(
grid
->
xdef
==
2
)
{
double
*
xvals
=
(
double
*
)
x
malloc
((
size_t
)
grid
->
xsize
*
sizeof
(
double
));
=
(
double
*
)
malloc
((
size_t
)
grid
->
xsize
*
sizeof
(
double
));
gridGenXvals
(
grid
->
xsize
,
grid
->
xfirst
,
grid
->
xlast
,
grid
->
xinc
,
xvals
);
gridDefXvals
(
gridID
,
xvals
);
free
(
xvals
);
...
...
@@ -2459,7 +2459,7 @@ int gridGenerate(const grid_t *grid)
else
if
(
grid
->
ydef
==
2
)
{
double
*
yvals
=
(
double
*
)
x
malloc
((
size_t
)
grid
->
ysize
*
sizeof
(
double
));
=
(
double
*
)
malloc
((
size_t
)
grid
->
ysize
*
sizeof
(
double
));
gridGenYvals
(
grid
->
type
,
grid
->
ysize
,
grid
->
yfirst
,
grid
->
ylast
,
grid
->
yinc
,
yvals
);
gridDefYvals
(
gridID
,
yvals
);
free
(
yvals
);
...
...
@@ -2544,7 +2544,7 @@ int gridGenerate(const grid_t *grid)
else
if
(
grid
->
ydef
==
2
)
{
double
*
yvals
=
(
double
*
)
x
malloc
((
size_t
)
grid
->
ysize
*
sizeof
(
double
));
=
(
double
*
)
malloc
((
size_t
)
grid
->
ysize
*
sizeof
(
double
));
gridGenYvals
(
grid
->
type
,
grid
->
ysize
,
grid
->
yfirst
,
grid
->
ylast
,
grid
->
yinc
,
yvals
);
gridDefYvals
(
gridID
,
yvals
);
free
(
yvals
);
...
...
@@ -2653,7 +2653,7 @@ int gridDuplicate(int gridID)
int
irregular
=
gridtype
==
GRID_CURVILINEAR
||
gridtype
==
GRID_UNSTRUCTURED
;
if
(
nrowlon
)
{
gridptrnew
->
rowlon
=
(
int
*
)
x
malloc
(
nrowlon
*
sizeof
(
int
));
gridptrnew
->
rowlon
=
(
int
*
)
malloc
(
nrowlon
*
sizeof
(
int
));
memcpy
(
gridptrnew
->
rowlon
,
gridptr
->
rowlon
,
nrowlon
*
sizeof
(
int
));
}
...
...
@@ -2661,7 +2661,7 @@ int gridDuplicate(int gridID)
{
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
xsize
);
gridptrnew
->
xvals
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptrnew
->
xvals
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
xvals
,
gridptr
->
xvals
,
size
*
sizeof
(
double
));
}
...
...
@@ -2669,7 +2669,7 @@ int gridDuplicate(int gridID)
{
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
ysize
);
gridptrnew
->
yvals
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptrnew
->
yvals
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
yvals
,
gridptr
->
yvals
,
size
*
sizeof
(
double
));
}
...
...
@@ -2678,7 +2678,7 @@ int gridDuplicate(int gridID)
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
xsize
)
*
(
size_t
)
gridptr
->
nvertex
;
gridptrnew
->
xbounds
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptrnew
->
xbounds
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
xbounds
,
gridptr
->
xbounds
,
size
*
sizeof
(
double
));
}
...
...
@@ -2687,7 +2687,7 @@ int gridDuplicate(int gridID)
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
ysize
)
*
(
size_t
)
gridptr
->
nvertex
;
gridptrnew
->
ybounds
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptrnew
->
ybounds
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
ybounds
,
gridptr
->
ybounds
,
size
*
sizeof
(
double
));
}
...
...
@@ -2695,7 +2695,7 @@ int gridDuplicate(int gridID)
{
size_t
size
=
(
size_t
)
gridsize
;
gridptrnew
->
area
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptrnew
->
area
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
area
,
gridptr
->
area
,
size
*
sizeof
(
double
));
}
...
...
@@ -2703,7 +2703,7 @@ int gridDuplicate(int gridID)
{
size_t
size
=
(
size_t
)
gridsize
;
gridptrnew
->
mask
=
(
mask_t
*
)
x
malloc
(
size
*
sizeof
(
mask_t
));
gridptrnew
->
mask
=
(
mask_t
*
)
malloc
(
size
*
sizeof
(
mask_t
));
memcpy
(
gridptrnew
->
mask
,
gridptr
->
mask
,
size
*
sizeof
(
mask_t
));
}
...
...
@@ -2711,7 +2711,7 @@ int gridDuplicate(int gridID)
{
size_t
size
=
(
size_t
)
gridsize
;
gridptrnew
->
mask_gme
=
(
mask_t
*
)
x
malloc
(
size
*
sizeof
(
mask_t
));
gridptrnew
->
mask_gme
=
(
mask_t
*
)
malloc
(
size
*
sizeof
(
mask_t
));
memcpy
(
gridptrnew
->
mask_gme
,
gridptr
->
mask_gme
,
size
*
sizeof
(
mask_t
));
}
...
...
@@ -2797,7 +2797,7 @@ void gridDefArea(int gridID, const double *area)
Error
(
"size undefined for gridID = %d"
,
gridID
);
if
(
gridptr
->
area
==
NULL
)
gridptr
->
area
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptr
->
area
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
else
if
(
CDI_Debug
)
Warning
(
"values already defined!"
);
...
...
@@ -2885,7 +2885,7 @@ void gridDefXbounds(int gridID, const double *xbounds)
Error
(
"size undefined for gridID = %d"
,
gridID
);
if
(
gridptr
->
xbounds
==
NULL
)
gridptr
->
xbounds
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptr
->
xbounds
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
else
if
(
CDI_Debug
)
Warning
(
"values already defined!"
);
...
...
@@ -2972,7 +2972,7 @@ void gridDefYbounds(int gridID, const double *ybounds)
Error
(
"size undefined for gridID = %d"
,
gridID
);
if
(
gridptr
->
ybounds
==
NULL
)
gridptr
->
ybounds
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptr
->
ybounds
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
else
if
(
CDI_Debug
)
Warning
(
"values already defined!"
);
...
...
@@ -3276,7 +3276,7 @@ void gridPrintKernel(grid_t * gridptr, int index, int opt, FILE *fp)
int
*
rowlon
;
nbyte0
=
fprintf
(
fp
,
"rowlon = "
);
nbyte
=
nbyte0
;
rowlon
=
(
int
*
)
x
malloc
((
size_t
)
ysize
*
sizeof
(
int
));
rowlon
=
(
int
*
)
malloc
((
size_t
)
ysize
*
sizeof
(
int
));
gridInqRowlon
(
gridID
,
rowlon
);
for
(
i
=
0
;
i
<
ysize
;
i
++
)
{
...
...
@@ -4077,7 +4077,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
if
(
memberMask
&
gridHasRowLonFlag
)
{
xassert
(
gridP
->
nrowlon
);
gridP
->
rowlon
=
(
int
*
)
x
malloc
((
size_t
)
gridP
->
nrowlon
*
sizeof
(
int
));
gridP
->
rowlon
=
(
int
*
)
malloc
((
size_t
)
gridP
->
nrowlon
*
sizeof
(
int
));
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
gridP
->
rowlon
,
gridP
->
nrowlon
,
DATATYPE_INT
,
context
);
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
...
...
@@ -4125,7 +4125,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
{
size
=
irregular
?
gridP
->
size
:
gridP
->
xsize
;
gridP
->
xvals
=
(
double
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
double
));
gridP
->
xvals
=
(
double
*
)
malloc
((
size_t
)
size
*
sizeof
(
double
));
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
gridP
->
xvals
,
size
,
DATATYPE_FLT64
,
context
);
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
...
...
@@ -4137,7 +4137,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
{
size
=
irregular
?
gridP
->
size
:
gridP
->
ysize
;
gridP
->
yvals
=
(
double
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
double
));
gridP
->
yvals
=
(
double
*
)
malloc
((
size_t
)
size
*
sizeof
(
double
));
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
gridP
->
yvals
,
size
,
DATATYPE_FLT64
,
context
);
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
...
...
@@ -4149,7 +4149,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
{
size
=
gridP
->
size
;
xassert
(
size
);
gridP
->
area
=
(
double
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
double
));
gridP
->
area
=
(
double
*
)
malloc
((
size_t
)
size
*
sizeof
(
double
));
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
gridP
->
area
,
size
,
DATATYPE_FLT64
,
context
);
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
...
...
@@ -4162,7 +4162,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
size
=
gridP
->
nvertex
*
(
irregular
?
gridP
->
size
:
gridP
->
xsize
);
xassert
(
size
);
gridP
->
xbounds
=
(
double
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
double
));
gridP
->
xbounds
=
(
double
*
)
malloc
((
size_t
)
size
*
sizeof
(
double
));
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
gridP
->
xbounds
,
size
,
DATATYPE_FLT64
,
context
);
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
...
...
@@ -4175,7 +4175,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
size
=
gridP
->
nvertex
*
(
irregular
?
gridP
->
size
:
gridP
->
ysize
);
xassert
(
size
);
gridP
->
ybounds
=
(
double
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
double
));
gridP
->
ybounds
=
(
double
*
)
malloc
((
size_t
)
size
*
sizeof
(
double
));
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
gridP
->
ybounds
,
size
,
DATATYPE_FLT64
,
context
);
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
...
...
@@ -4195,7 +4195,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
int
referenceSize
;
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
&
referenceSize
,
1
,
DATATYPE_INT
,
context
);
gridP
->
reference
=
(
char
*
)
x
malloc
((
size_t
)
referenceSize
);
gridP
->
reference
=
(
char
*
)
malloc
((
size_t
)
referenceSize
);
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
gridP
->
reference
,
referenceSize
,
DATATYPE_TXT
,
context
);
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
...
...
@@ -4206,7 +4206,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
if
(
memberMask
&
gridHasMaskFlag
)
{
xassert
((
size
=
gridP
->
size
));
gridP
->
mask
=
(
mask_t
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
gridP
->
mask
=
(
mask_t
*
)
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
gridP
->
mask
,
gridP
->
size
,
DATATYPE_UCHAR
,
context
);
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
...
...
@@ -4217,7 +4217,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
if
(
memberMask
&
gridHasGMEMaskFlag
)
{
xassert
((
size
=
gridP
->
size
));
gridP
->
mask_gme
=
(
mask_t
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
gridP
->
mask_gme
=
(
mask_t
*
)
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
gridP
->
mask_gme
,
gridP
->
size
,
DATATYPE_UCHAR
,
context
);
serializeUnpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
...
...
src/input_file.c
View file @
2da6059b
...
...
@@ -73,7 +73,7 @@ CdiInputFile* cdiInputFile_make(const char* path)
}
else
{
result
=
(
CdiInputFile
*
)
x
malloc
(
sizeof
(
*
result
));
result
=
(
CdiInputFile
*
)
malloc
(
sizeof
(
*
result
));
if
(
!
cdiInputFile_condestruct
(
result
,
path
))
{
//An error occured during construction, avoid a memory leak.
...
...
src/institution.c
View file @
2da6059b
...
...
@@ -151,7 +151,7 @@ findInstitute(int id, void *res, void *data)
int
institutInq
(
int
center
,
int
subcenter
,
const
char
*
name
,
const
char
*
longname
)
{
institute_t
*
ip_ref
=
(
institute_t
*
)
x
malloc
(
sizeof
(
*
ip_ref
));
institute_t
*
ip_ref
=
(
institute_t
*
)
malloc
(
sizeof
(
*
ip_ref
));
ip_ref
->
self
=
UNDEFID
;
ip_ref
->
used
=
0
;
ip_ref
->
center
=
center
;
...
...
@@ -171,7 +171,7 @@ static
institute_t
*
instituteNewEntry
(
cdiResH
resH
,
int
center
,
int
subcenter
,
const
char
*
name
,
const
char
*
longname
)
{
institute_t
*
instituteptr
=
(
institute_t
*
)
x
malloc
(
sizeof
(
institute_t
));
institute_t
*
instituteptr
=
(
institute_t
*
)
malloc
(
sizeof
(
institute_t
));
instituteDefaultValue
(
instituteptr
);
if
(
resH
==
CDI_UNDEFID
)
instituteptr
->
self
=
reshPut
(
instituteptr
,
&
instituteOps
);
...
...
@@ -333,7 +333,7 @@ int instituteUnpack(void *buf, int size, int *position, int originNamespace,
int
instituteID
;
char
*
name
,
*
longname
;
serializeUnpack
(
buf
,
size
,
position
,
tempbuf
,
institute_nints
,
DATATYPE_INT
,
context
);
name
=
(
char
*
)
x
malloc
((
size_t
)
tempbuf
[
3
]
+
(
size_t
)
tempbuf
[
4
]);
name
=
(
char
*
)
malloc
((
size_t
)
tempbuf
[
3
]
+
(
size_t
)
tempbuf
[
4
]);
longname
=
name
+
tempbuf
[
3
];
serializeUnpack
(
buf
,
size
,
position
,
name
,
tempbuf
[
3
],
DATATYPE_TXT
,
context
);
serializeUnpack
(
buf
,
size
,
position
,
longname
,
tempbuf
[
4
],
DATATYPE_TXT
,
context
);
...
...
src/iterator.c
View file @
2da6059b
...
...
@@ -301,7 +301,7 @@ char* cdiIterator_serialize(CdiIterator* me)
const
char
*
ftypeStr
=
fileType2String
(
me
->
filetype
),
*
advStr
=
me
->
isAdvanced
?
kAdvancedString
:
kUnadvancedString
;
char
*
result
=
(
char
*
)
x
malloc
(
strlen
(
ftypeStr
)
+
1
+
strlen
(
advStr
)
+
1
char
*
result
=
(
char
*
)
malloc
(
strlen
(
ftypeStr
)
+
1
+
strlen
(
advStr
)
+
1
+
strlen
(
subclassDescription
)
+
1
);
sprintf
(
result
,
"%s %s %s"
,
ftypeStr
,
advStr
,
subclassDescription
);
free
(
subclassDescription
);
...
...
src/iterator_fallback.c
View file @
2da6059b
...
...
@@ -30,7 +30,7 @@ static CdiFallbackIterator *cdiFallbackIterator_condestruct(CdiFallbackIterator
{
if
(
me
)
goto
destruct
;
me
=
(
CdiFallbackIterator
*
)
x
malloc
(
sizeof
(
*
me
));
me
=
(
CdiFallbackIterator
*
)
malloc
(
sizeof
(
*
me
));
baseIterConstruct
(
&
me
->
super
,
filetype
);
me
->
streamId
=
streamOpenRead
(
path
);
...
...
@@ -106,7 +106,7 @@ char *cdiFallbackIterator_serialize(CdiIterator *super)
CdiFallbackIterator
*
me
=
(
CdiFallbackIterator
*
)
super
;
char
*
escapedPath
=
cdiEscapeSpaces
(
me
->
path
);
char
*
result
=
(
char
*
)
x
malloc
(
strlen
(
escapedPath
)
char
*
result
=
(
char
*
)
malloc
(
strlen
(
escapedPath
)
+
5
*
(
3
*
sizeof
(
int
)
*
CHAR_BIT
/
8
+
1
)
+
1
);
sprintf
(
result
,
"%s %d %d %d %d %d"
,
escapedPath
,
me
->
variableCount
,
me
->
curVariable
,
me
->
curLevelCount
,
me
->
curLevel
,
me
->
curTimestep
);
free
(
escapedPath
);
...
...
@@ -115,7 +115,7 @@ char *cdiFallbackIterator_serialize(CdiIterator *super)
CdiFallbackIterator
*
cdiFallbackIterator_deserialize
(
const
char
*
description
)
{
CdiFallbackIterator
*
me
=
(
CdiFallbackIterator
*
)
x
malloc
(
sizeof
(
*
me
));
CdiFallbackIterator
*
me
=
(
CdiFallbackIterator
*
)
malloc
(
sizeof
(
*
me
));
if
(
!
me
)
goto
fail
;
description
=
baseIter_constructFromString
(
&
me
->
super
,
description
);
...
...
@@ -203,7 +203,7 @@ char *cdiFallbackIterator_inqTime(CdiIterator *super, bool getEndTime)
cdiDecodeDate
(
date
,
&
year
,
&
month
,
&
day
);
cdiDecodeTime
(
time
,
&
hour
,
&
minute
,
&
second
);
char
*
result
=
(
char
*
)
x
malloc
(
4
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
4
+
1
);
=
(
char
*
)
malloc
(
4
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
4
+
1
);
sprintf
(
result
,
"%04d-%02d-%02dT%02d:%02d:%02d.000"
,
year
,
month
,
day
,
hour
,
minute
,
second
);
return
result
;
}
...
...
src/iterator_grib.c
View file @
2da6059b
...
...
@@ -46,7 +46,7 @@ static CdiGribIterator *cdiGribIterator_condestruct(CdiGribIterator *me, const c
{
#define super() (&me->super)
if
(
me
)
goto
destruct
;
me
=
(
CdiGribIterator
*
)
x
malloc
(
sizeof
(
*
me
));
me
=
(
CdiGribIterator
*
)
malloc
(
sizeof
(
*
me
));
baseIterConstruct
(
super
(),
filetype
);
me
->
file
=
cdiInputFile_make
(
path
);
...
...
@@ -88,7 +88,7 @@ CdiGribIterator *cdiGribIterator_makeClone(CdiIterator *super)
CdiGribIterator
*
me
=
(
CdiGribIterator
*
)
super
;
//Allocate memory and copy data. (operations that may fail)
CdiGribIterator
*
result
=
(
struct
CdiGribIterator
*
)
x
malloc
(
sizeof
(
*
result
));
CdiGribIterator
*
result
=
(
struct
CdiGribIterator
*
)
malloc
(
sizeof
(
*
result
));
if
(
!
result
)
goto
fail
;
result
->
file
=
me
->
file
;
...
...
@@ -100,7 +100,7 @@ CdiGribIterator *cdiGribIterator_makeClone(CdiIterator *super)
if
(
me
->
gribBuffer
)
{
result
->
gribBuffer
=
(
unsigned
char
*
)
x
malloc
(
me
->
bufferSize
);
result
->
gribBuffer
=
(
unsigned
char
*
)
malloc
(
me
->
bufferSize
);
if
(
!
result
->
gribBuffer
)
goto
freeResult
;
memcpy
(
result
->
gribBuffer
,
me
->
gribBuffer
,
me
->
curRecordSize
);
}
...
...
@@ -141,7 +141,7 @@ char *cdiGribIterator_serialize(CdiIterator *super)
const
char
*
path
=
(
char
*
)
cdiInputFile_getPath
(
me
->
file
);
char
*
escapedPath
=
(
char
*
)
cdiEscapeSpaces
(
path
);
char
*
result
=
(
char
*
)
x
malloc
(
strlen
(
escapedPath
)
+
3
*
sizeof
(
int
)
*
CHAR_BIT
/
8
);
char
*
result
=
(
char
*
)
malloc
(
strlen
(
escapedPath
)
+
3
*
sizeof
(
int
)
*
CHAR_BIT
/
8
);
sprintf
(
result
,
"%s %zu"
,
escapedPath
,
me
->
fileOffset
);
free
(
escapedPath
);
return
result
;
...
...
@@ -151,7 +151,7 @@ char *cdiGribIterator_serialize(CdiIterator *super)
CdiGribIterator
*
cdiGribIterator_deserialize
(
const
char
*
description
)
{
char
*
path
;
CdiGribIterator
*
me
=
(
CdiGribIterator
*
)
x
malloc
(
sizeof
(
*
me
));
CdiGribIterator
*
me
=
(
CdiGribIterator
*
)
malloc
(
sizeof
(
*
me
));
if
(
!
me
)
goto
fail
;
description
=
baseIter_constructFromString
(
&
me
->
super
,
description
);
...
...
src/model.c
View file @
2da6059b
...
...
@@ -67,7 +67,7 @@ modelNewEntry(cdiResH resH, int instID, int modelgribID, const char *name)
{
model_t
*
modelptr
;
modelptr
=
(
model_t
*
)
x
malloc
(
sizeof
(
model_t
));
modelptr
=
(
model_t
*
)
malloc
(
sizeof
(
model_t
));
modelDefaultValue
(
modelptr
);
if
(
resH
==
CDI_UNDEFID
)
modelptr
->
self
=
reshPut
(
modelptr
,
&
modelOps
);
...
...
@@ -326,7 +326,7 @@ modelUnpack(void *buf, int size, int *position, int originNamespace, void *conte
serializeUnpack
(
buf
,
size
,
position
,
tempbuf
,
model_nints
,
DATATYPE_INT
,
context
);
if
(
tempbuf
[
3
]
!=
0
)
{
name
=
(
char
*
)
x
malloc
((
size_t
)
tempbuf
[
3
]);
name
=
(
char
*
)
malloc
((
size_t
)
tempbuf
[
3
]);
serializeUnpack
(
buf
,
size
,
position
,
name
,
tempbuf
[
3
],
DATATYPE_TXT
,
context
);
}
...
...
src/namespace.c
View file @
2da6059b
...
...
@@ -162,7 +162,7 @@ namespaceNew()
{
/* make room for additional namespace */
struct
Namespace
*
newNameSpaces
=
(
struct
Namespace
*
)
x
malloc
(((
size_t
)
namespacesSize
+
1
)
*
sizeof
(
namespaces
[
0
]));
=
(
struct
Namespace
*
)
malloc
(((
size_t
)
namespacesSize
+
1
)
*
sizeof
(
namespaces
[
0
]));
memcpy
(
newNameSpaces
,
namespaces
,
sizeof
(
namespaces
[
0
]));
namespaces
=
newNameSpaces
;
++
namespacesSize
;
...
...
src/pio_comm.c
View file @
2da6059b
...
...
@@ -382,7 +382,7 @@ void commDefCommNode ( void )
size
=
info
->
sizePio
;
myHost
=
(
char
*
)
x
malloc
(
MPI_MAX_PROCESSOR_NAME
);
myHost
=
(
char
*
)
malloc
(
MPI_MAX_PROCESSOR_NAME
);
{
int
len
;
xmpi
(
MPI_Get_processor_name
(
myHost
,
&
len
));
...
...
@@ -391,8 +391,8 @@ void commDefCommNode ( void )
info
->
hostname
[
len
]
=
'\0'
;
}
allHosts
=
x
malloc
((
size_t
)
size
*
MPI_MAX_PROCESSOR_NAME
);
sortedHosts
=
x
malloc
((
size_t
)
size
*
sizeof
(
sortedHosts
[
0
]));
allHosts
=
malloc
((
size_t
)
size
*
MPI_MAX_PROCESSOR_NAME
);
sortedHosts
=
malloc
((
size_t
)
size
*
sizeof
(
sortedHosts
[
0
]));
for
(
int
i
=
0
;
i
<
size
;
++
i
)
sortedHosts
[
i
]
=
allHosts
[
i
];
...
...
@@ -507,7 +507,7 @@ void commRecvNodeMap ( void )
xdebug
(
"info->nProcsColl=%d"
,
info
->
nProcsColl
);
info
->
nodeMap
=
(
int
*
)
x
malloc
((
size_t
)
info
->
nProcsColl
info
->
nodeMap
=
(
int
*
)
malloc
((
size_t
)
info
->
nProcsColl
*
sizeof
(
info
->
nodeMap
[
0
]));
xmpi
(
MPI_Recv
(
info
->
nodeMap
,
info
->
nProcsColl
,
MPI_INTEGER
,
...
...
@@ -547,7 +547,7 @@ void commEvalPhysNodes ( void )
size
=
info
->
nProcsIO
*
sizeNodeInfo
;
nodeInfo
=
(
nodeInfo_t
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
int
));
nodeInfo
=
(
nodeInfo_t
*
)
malloc
((
size_t
)
size
*
sizeof
(
int
));
if
(
info
->
rankGlob
==
info
->
root
)
{
...
...
@@ -587,7 +587,7 @@ void commEvalPhysNodes ( void )
xassert
(
info
->
nProcsColl
<=
info
->
nProcsModel
);
info
->
procsCollMap
=
(
int
*
)
x
malloc
((
size_t
)
info
->
nProcsColl
info
->
procsCollMap
=
(
int
*
)
malloc
((
size_t
)
info
->
nProcsColl
*
sizeof
(
info
->
procsCollMap
[
0
]));
// define nodeSizes
...
...
@@ -603,11 +603,11 @@ void commEvalPhysNodes ( void )
}
// define nodeMap
info
->
nodeMap
=
(
int
*
)
x
malloc
((
size_t
)
info
->
nProcsColl
info
->
nodeMap
=
(
int
*
)
malloc
((
size_t
)
info
->
nProcsColl
*
sizeof
(
info
->
nodeMap
[
0
]));
// helpers
p1
=
(
int
**
)
x
malloc
((
size_t
)
info
->
nodeInfo
.
nNodes
*
sizeof
(
p1
[
0
]));
p2
=
(
int
**
)
x
malloc
((
size_t
)
info
->
nodeInfo
.
nNodes
*
sizeof
(
p2
[
0
]));
p1
=
(
int
**
)
malloc
((
size_t
)
info
->
nodeInfo
.
nNodes
*
sizeof
(
p1
[
0
]));
p2
=
(
int
**
)
malloc
((
size_t
)
info
->
nodeInfo
.
nNodes
*
sizeof
(
p2
[
0
]));
idx
=
0
;
for
(
i
=
0
;
i
<
info
->
nodeInfo
.
nNodes
;
i
++
)
{
...
...
@@ -689,7 +689,7 @@ void commDefCommsIO ( void )
info
->
nProcsModel
!=
CDI_UNDEFID
&&
info
->
commGlob
!=
MPI_COMM_NULL
);
info
->
commsIO
=
(
MPI_Comm
*
)
x
malloc
((
size_t
)
info
->
nProcsColl
info
->
commsIO
=
(
MPI_Comm
*
)
malloc
((
size_t
)
info
->
nProcsColl
*
sizeof
(
info
->
commsIO
[
0
]));
for
(
collID
=
0
;
collID
<
info
->
nProcsColl
;
collID
++
)
info
->
commsIO
[
collID
]
=
MPI_COMM_NULL
;
...
...
@@ -697,7 +697,7 @@ void commDefCommsIO ( void )
strncpy
(
name
,
"COMMSIO_"
,
8
);
name
[
MAXCOMMIONAME
-
1
]
=
'\0'
;
ranks
=
(
int
*
)
x
malloc
(((
size_t
)
info
->
nProcsModel
+
1
)
*
sizeof
(
ranks
[
0
]));
ranks
=
(
int
*
)
malloc
(((
size_t
)
info
->
nProcsModel
+
1
)
*
sizeof
(
ranks
[
0
]));
for
(
i
=
0
;
i
<
info
->
nProcsModel
;
i
++
)
ranks
[
i
]
=
i
;
...
...
src/pio_interface.c
View file @
2da6059b
...
...
@@ -178,7 +178,7 @@ varMapGen(int *vSizes, int *sSizes, int *varMapping,
weightsStreams
[
i
]
+=
*
(
vSizes
+
offset
++
);
}
double
*
w
=
(
double
*
)
x
malloc
((
size_t
)
nNodes
*
sizeof
(
double
));
double
*
w
=
(
double
*
)
malloc
((
size_t
)
nNodes
*
sizeof
(
double
));
for
(
j
=
0
;
j
<
nNodes
;
j
++
)
nPEs
+=
*
(
nodeSizes
+
j
);
...
...
@@ -195,9 +195,9 @@ varMapGen(int *vSizes, int *sSizes, int *varMapping,
if
(
*
(
streamMapping
+
j
)
==
i
)
nVarsNode
+=
*
(
sSizes
+
j
);
weightsVarsNode
=
x
malloc
((
size_t
)
nVarsNode
*
sizeof
(
int
));
varMappingNode
=
x
malloc
((
size_t
)
nVarsNode
*
sizeof
(
int
));
w
=
x
malloc
((
size_t
)
nodeSizes
[
i
]
*
sizeof
(
double
));
weightsVarsNode
=
malloc
((
size_t
)
nVarsNode
*
sizeof
(
int
));
varMappingNode
=
malloc
((
size_t
)
nVarsNode
*
sizeof
(
int
));
w
=
malloc
((
size_t
)
nodeSizes
[
i
]
*
sizeof
(
double
));
offset
=
0
;
offsetN
=
0
;
...
...
@@ -258,9 +258,9 @@ varsMapNDeco(int nNodes, int *nodeSizes)
unsigned
nStreams
=
reshCountType
(
&
streamOps
);
resHs
=
x
malloc
(
nStreams
*
sizeof
(
resHs
[
0
]));
streamSizes
=
x
malloc
(
nStreams
*
sizeof
(
streamSizes
[
0
]));
collectsData
=
x
malloc
((
size_t
)
nProcsColl
*
sizeof
(
collectsData
[
0
]));
resHs
=
malloc
(
nStreams
*
sizeof
(
resHs
[
0
]));
streamSizes
=
malloc
(
nStreams
*
sizeof
(
streamSizes
[
0
]));
collectsData
=
malloc
((
size_t
)
nProcsColl
*
sizeof
(
collectsData
[
0
]));
cdiStreamGetIndexList
(
nStreams
,
resHs
);
for
(
unsigned
i
=
0
;
i
<
nStreams
;
i
++
)
...
...
@@ -268,7 +268,7 @@ varsMapNDeco(int nNodes, int *nodeSizes)
nVars
=
sum_int
((
size_t
)
nStreams
,
streamSizes
);
varSizes
=
xcalloc
((
size_t
)
nVars
,
sizeof
(
varSizes
[
0
]));