summaryrefslogtreecommitdiffstats
path: root/src/H5G.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2015-09-14 03:58:59 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2015-09-14 03:58:59 (GMT)
commit102337449220dfc29be1cce29147704b9c760832 (patch)
tree2f57d117f2bd934eac2768be18dcc866619f390f /src/H5G.c
parentf16361d5f1dc70c344d8143270aa4aeaa867f244 (diff)
downloadhdf5-102337449220dfc29be1cce29147704b9c760832.zip
hdf5-102337449220dfc29be1cce29147704b9c760832.tar.gz
hdf5-102337449220dfc29be1cce29147704b9c760832.tar.bz2
[svn-r27768] Description:
Complete revamp of package initialization/shutdown mechanism in the library. Each package now has a single init/term routine. This new way should avoid packages being re-initialized during library shutdown and is also be _much_ more proactive about giving feedback for resource leaks internal to the library. Introduces a new "module" header file for packages in the library (e.g src/H5Fmodule.h) which sets up some necessary package configuration macros for the FUNC_ENTER/LEAVE macros. (The VFL drivers have their own slightly modified version of this header, src/H5FDdrvr_module.h) Also cleaned up a bunch of resources leaks all across the library and tests, along with addressing many warnings, as I encountered them. Tested on: MacOSX/64 10.10.5 (amazon) w/serial & parallel Linux/64 3.10.x (kituo) w/serial & parallel Linux/64 2.6.x (ostrich) w/serial
Diffstat (limited to 'src/H5G.c')
-rw-r--r--src/H5G.c117
1 files changed, 65 insertions, 52 deletions
diff --git a/src/H5G.c b/src/H5G.c
index 8fd65b8..089dc50 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -79,10 +79,7 @@
/* Module Setup */
/****************/
-#define H5G_PACKAGE /*suppress error about including H5Gpkg */
-
-/* Interface initialization */
-#define H5_INTERFACE_INIT_FUNC H5G_init_interface
+#include "H5Gmodule.h" /* This source code file is part of the H5G module */
/***********/
@@ -120,6 +117,9 @@
/* Package Variables */
/*********************/
+/* Package initialization variable */
+hbool_t H5_PKG_INIT_VAR = FALSE;
+
/*****************************/
/* Library Private Variables */
@@ -138,36 +138,13 @@ static const H5I_class_t H5I_GROUP_CLS[1] = {{
(H5I_free_t)H5G_close /* Callback routine for closing objects of this class */
}};
+/* Flag indicating "top" of interface has been initialized */
+static hbool_t H5G_top_package_initialize_s = FALSE;
-
-/*-------------------------------------------------------------------------
- * Function: H5G__init
- *
- * Purpose: Initialize the interface from some other package.
- *
- * Return: Success: non-negative
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Saturday, November 11, 2006
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5G__init(void)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
- /* FUNC_ENTER() does all the work */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G__init() */
/*-------------------------------------------------------------------------
- * Function: H5G_init_interface
+ * Function: H5G__init_package
*
* Purpose: Initializes the H5G interface.
*
@@ -177,7 +154,7 @@ done:
* Monday, January 5, 1998
*
* Notes: The group creation properties are registered in the property
- * list interface initialization routine (H5P_init_interface)
+ * list interface initialization routine (H5P_init_package)
* so that the file creation property class can inherit from it
* correctly. (Which allows the file creation property list to
* control the group creation properties of the root group of
@@ -185,64 +162,100 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5G_init_interface(void)
+herr_t
+H5G__init_package(void)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Initialize the atom group for the group IDs */
if(H5I_register_type(H5I_GROUP_CLS) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface")
+ /* Mark "top" of interface as initialized, too */
+ H5G_top_package_initialize_s = TRUE;
+
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_init_interface() */
+} /* end H5G__init_package() */
/*-------------------------------------------------------------------------
- * Function: H5G_term_interface
+ * Function: H5G_top_term_package
*
- * Purpose: Terminates the H5G interface
+ * Purpose: Close the "top" of the interface, releasing IDs, etc.
*
* Return: Success: Positive if anything is done that might
* affect other interfaces; zero otherwise.
- *
* Failure: Negative.
*
- * Programmer: Robb Matzke
- * Monday, January 5, 1998
+ * Programmer: Quincey Koziol
+ * Sunday, September 13, 2015
*
*-------------------------------------------------------------------------
*/
int
-H5G_term_interface(void)
+H5G_top_term_package(void)
{
int n = 0;
FUNC_ENTER_NOAPI_NOINIT_NOERR
- if(H5_interface_initialize_g) {
+ if(H5G_top_package_initialize_s) {
if(H5I_nmembers(H5I_GROUP) > 0) {
(void)H5I_clear_type(H5I_GROUP, FALSE, FALSE);
n++; /*H5I*/
} /* end if */
- else {
- /* Close deprecated interface */
- n += H5G__term_deprec_interface();
- /* Destroy the group object id group */
- (void)H5I_dec_type_ref(H5I_GROUP);
- n++; /*H5I*/
+ /* Mark closed */
+ if(0 == n)
+ H5G_top_package_initialize_s = FALSE;
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(n)
+} /* end H5G_top_term_package() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_term_package
+ *
+ * Purpose: Terminates the H5G interface
+ *
+ * Note: Finishes shutting down the interface, after
+ * H5G_top_term_package() is called
+ *
+ * Return: Success: Positive if anything is done that might
+ * affect other interfaces; zero otherwise.
+ * Failure: Negative.
+ *
+ * Programmer: Robb Matzke
+ * Monday, January 5, 1998
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+H5G_term_package(void)
+{
+ int n = 0;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ if(H5_PKG_INIT_VAR) {
+ /* Sanity checks */
+ HDassert(0 == H5I_nmembers(H5I_GROUP));
+ HDassert(FALSE == H5G_top_package_initialize_s);
+
+ /* Destroy the group object id group */
+ n += (H5I_dec_type_ref(H5I_GROUP) > 0);
- /* Mark closed */
- H5_interface_initialize_g = 0;
- } /* end else */
+ /* Mark closed */
+ if(0 == n)
+ H5_PKG_INIT_VAR = FALSE;
} /* end if */
FUNC_LEAVE_NOAPI(n)
-} /* end H5G_term_interface() */
+} /* end H5G_term_package() */
/*-------------------------------------------------------------------------