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
8fb8573e
Commit
8fb8573e
authored
Feb 06, 2011
by
Uwe Schulzweida
Browse files
vlistDestroy: fix memory leak
parent
51cbea18
Changes
3
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
8fb8573e
2011-02-06 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* vlistDestroy: fix memory leak [report: Luis Kornblueh]
2011-01-25 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added netCDF support for level bounds
2011-01-21 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added grid type GRID_NUMBER
* changed grid name GRID_CELL to GRID_UNSTRUCTURED
2011-01-19 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added support to encode/decode GRIB1 with GRIB_API
2011-01-03 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using CGRIBEX library version 1.4.7
...
...
src/vlist.c
View file @
8fb8573e
...
...
@@ -335,7 +335,11 @@ void vlistDestroy(int vlistID)
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
{
if
(
vlistptr
->
vars
[
varID
].
levinfo
)
free
(
vlistptr
->
vars
[
varID
].
levinfo
);
if
(
vlistptr
->
vars
[
varID
].
levinfo
)
free
(
vlistptr
->
vars
[
varID
].
levinfo
);
if
(
vlistptr
->
vars
[
varID
].
name
)
free
(
vlistptr
->
vars
[
varID
].
name
);
if
(
vlistptr
->
vars
[
varID
].
longname
)
free
(
vlistptr
->
vars
[
varID
].
longname
);
if
(
vlistptr
->
vars
[
varID
].
stdname
)
free
(
vlistptr
->
vars
[
varID
].
stdname
);
if
(
vlistptr
->
vars
[
varID
].
units
)
free
(
vlistptr
->
vars
[
varID
].
units
);
vlistDelAtts
(
vlistID
,
varID
);
}
...
...
src/zaxis.c
View file @
8fb8573e
...
...
@@ -72,16 +72,16 @@ static int _zaxis_init = FALSE;
static
pthread_once_t
_zaxis_init_thread
=
PTHREAD_ONCE_INIT
;
static
pthread_mutex_t
_zaxis_mutex
;
# define ZAXIS_LOCK
pthread_mutex_lock(&_zaxis_mutex);
# define ZAXIS_UNLOCK
pthread_mutex_unlock(&_zaxis_mutex);
# define ZAXIS_INIT
\
# define ZAXIS_LOCK
()
pthread_mutex_lock(&_zaxis_mutex);
# define ZAXIS_UNLOCK
()
pthread_mutex_unlock(&_zaxis_mutex);
# define ZAXIS_INIT
()
\
if ( _zaxis_init == FALSE ) pthread_once(&_zaxis_init_thread, zaxis_initialize);
#else
# define ZAXIS_LOCK
# define ZAXIS_UNLOCK
# define ZAXIS_INIT
\
# define ZAXIS_LOCK
()
# define ZAXIS_UNLOCK
()
# define ZAXIS_INIT
()
\
if ( _zaxis_init == FALSE ) zaxis_initialize();
#endif
...
...
@@ -134,15 +134,15 @@ zaxis_t *zaxis_to_pointer(int idx)
{
zaxis_t
*
zaxisptr
=
NULL
;
ZAXIS_INIT
ZAXIS_INIT
();
if
(
idx
>=
0
&&
idx
<
_zaxis_max
)
{
ZAXIS_LOCK
ZAXIS_LOCK
();
zaxisptr
=
_zaxisList
[
idx
].
ptr
;
ZAXIS_UNLOCK
ZAXIS_UNLOCK
();
}
else
Error
(
"zaxis index %d undefined!"
,
idx
);
...
...
@@ -159,7 +159,7 @@ int zaxis_from_pointer(zaxis_t *ptr)
if
(
ptr
)
{
ZAXIS_LOCK
ZAXIS_LOCK
();
if
(
_zaxisAvail
)
{
...
...
@@ -175,7 +175,7 @@ int zaxis_from_pointer(zaxis_t *ptr)
else
Warning
(
"Too many open zaxis (limit is %d)!"
,
_zaxis_max
);
ZAXIS_UNLOCK
ZAXIS_UNLOCK
();
}
else
Error
(
"Internal problem (pointer %p undefined)"
,
ptr
);
...
...
@@ -223,7 +223,7 @@ void zaxis_delete_entry(zaxis_t *zaxisptr)
idx
=
zaxisptr
->
self
;
ZAXIS_LOCK
ZAXIS_LOCK
();
free
(
zaxisptr
);
...
...
@@ -231,7 +231,7 @@ void zaxis_delete_entry(zaxis_t *zaxisptr)
_zaxisList
[
idx
].
ptr
=
0
;
_zaxisAvail
=
&
_zaxisList
[
idx
];
ZAXIS_UNLOCK
ZAXIS_UNLOCK
();
if
(
ZAXIS_Debug
)
Message
(
"Removed idx %d from zaxis list"
,
idx
);
...
...
@@ -253,11 +253,11 @@ void zaxis_initialize(void)
zaxis_list_new
();
atexit
(
zaxis_list_delete
);
ZAXIS_LOCK
ZAXIS_LOCK
();
zaxis_init_pointer
();
ZAXIS_UNLOCK
ZAXIS_UNLOCK
();
_zaxis_init
=
TRUE
;
}
...
...
@@ -286,14 +286,14 @@ int zaxisSize(void)
int
zaxissize
=
0
;
int
i
;
ZAXIS_INIT
ZAXIS_INIT
();
ZAXIS_LOCK
ZAXIS_LOCK
();
for
(
i
=
0
;
i
<
_zaxis_max
;
i
++
)
if
(
_zaxisList
[
i
].
ptr
)
zaxissize
++
;
ZAXIS_UNLOCK
ZAXIS_UNLOCK
();
return
(
zaxissize
);
}
...
...
@@ -344,7 +344,7 @@ int zaxisCreate(int zaxistype, int size)
if
(
CDI_Debug
)
Message
(
"zaxistype: %d size: %d "
,
zaxistype
,
size
);
ZAXIS_INIT
ZAXIS_INIT
();
zaxisptr
=
zaxis_new_entry
();
if
(
!
zaxisptr
)
Error
(
"No memory"
);
...
...
@@ -388,6 +388,10 @@ void zaxisDestroy(int zaxisID)
zaxisptr
=
zaxis_to_pointer
(
zaxisID
);
zaxis_check_ptr
(
zaxisID
,
zaxisptr
);
if
(
zaxisptr
->
vals
)
free
(
zaxisptr
->
vals
);
zaxis_delete_entry
(
zaxisptr
);
}
...
...
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