summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-04-18 03:55:45 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-04-18 03:55:45 (GMT)
commitbcab84db9f291920ed0fe321116405f73eaddfa5 (patch)
tree7262020d64a762c7f88209b9af7fd6a3c2471164
parent188539f65e5de800ab63e68093c8e453e8c451c4 (diff)
downloadhdf5-bcab84db9f291920ed0fe321116405f73eaddfa5.zip
hdf5-bcab84db9f291920ed0fe321116405f73eaddfa5.tar.gz
hdf5-bcab84db9f291920ed0fe321116405f73eaddfa5.tar.bz2
Resolve memory leak of last API context, by freeing it in H5CX terminate
routine.
-rw-r--r--src/H5.c3
-rw-r--r--src/H5CX.c42
-rw-r--r--src/H5CXprivate.h1
3 files changed, 11 insertions, 35 deletions
diff --git a/src/H5.c b/src/H5.c
index f3e56d0..552330d 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -415,8 +415,7 @@ H5_term_library(void)
/* Mark library as closed */
H5_INIT_GLOBAL = FALSE;
- /* Don't pop the API context, since it's been shut down already */
- /* H5CX_pop_special(); */
+ /* Don't pop the API context (i.e. H5CX_pop), since it's been shut down already */
done:
#ifdef H5_HAVE_THREADSAFE
diff --git a/src/H5CX.c b/src/H5CX.c
index af2619b..c81a0f4 100644
--- a/src/H5CX.c
+++ b/src/H5CX.c
@@ -535,6 +535,16 @@ H5CX_term_package(void)
FUNC_ENTER_NOAPI_NOINIT_NOERR
if(H5_PKG_INIT_VAR) {
+ H5CX_node_t *cnode; /* Context node */
+
+ /* Pop the top context node from the stack */
+ /* (Can't check for errors, as rest of library is shut down) */
+ cnode = H5CX__pop_common();
+
+ /* Free the context node */
+ /* (Allocated with HDmalloc() in H5CX_push_special() ) */
+ HDfree(cnode);
+
#ifndef H5_HAVE_THREADSAFE
/* Release pointer to head of API context stack */
HDfree(H5CX_head_g);
@@ -2810,35 +2820,3 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5CX_pop() */
-
-/*-------------------------------------------------------------------------
- * Function: H5CX_pop_special
- *
- * Purpose: Pops the context for an API call, without using library routines.
- *
- * Note: This should only be called in special circumstances, like H5close.
- *
- * Return: <none>
- *
- * Programmer: Quincey Koziol
- * Februrary 22, 2018
- *
- *-------------------------------------------------------------------------
- */
-void
-H5CX_pop_special(void)
-{
- H5CX_node_t *cnode; /* Context node */
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Perform common operations and get top context from stack */
- cnode = H5CX__pop_common();
- HDassert(cnode);
-
- /* Free the context node */
- HDfree(cnode);
-
- FUNC_LEAVE_NOAPI_VOID
-} /* end H5CX_pop_special() */
-
diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h
index 78f4793..3566f11 100644
--- a/src/H5CXprivate.h
+++ b/src/H5CXprivate.h
@@ -56,7 +56,6 @@ H5_DLL herr_t H5CX_pop(void);
#endif /* _H5private_H */
H5_DLL void H5CX_push_special(void);
H5_DLL hbool_t H5CX_is_def_dxpl(void);
-H5_DLL void H5CX_pop_special(void);
/* "Setter" routines for API context info */
H5_DLL void H5CX_set_dxpl(hid_t dxpl_id);