summaryrefslogtreecommitdiffstats
path: root/src/H5F.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/H5F.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/H5F.c')
-rw-r--r--src/H5F.c70
1 files changed, 20 insertions, 50 deletions
diff --git a/src/H5F.c b/src/H5F.c
index d3b9fc8..041bd35 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -17,10 +17,7 @@
/* Module Setup */
/****************/
-#define H5F_PACKAGE /*suppress error about including H5Fpkg */
-
-/* Interface initialization */
-#define H5_INTERFACE_INIT_FUNC H5F__init_pub_interface
+#include "H5Fmodule.h" /* This source code file is part of the H5F module */
/***********/
@@ -66,6 +63,9 @@
/* Package Variables */
/*********************/
+/* Package initialization variable */
+hbool_t H5_PKG_INIT_VAR = FALSE;
+
/*****************************/
/* Library Private Variables */
@@ -88,21 +88,21 @@ static const H5I_class_t H5I_FILE_CLS[1] = {{
/*--------------------------------------------------------------------------
NAME
- H5F__init_pub_interface -- Initialize interface-specific information
+ H5F__init_package -- Initialize interface-specific information
USAGE
- herr_t H5F__init_pub_interface()
+ herr_t H5F__init_package()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
- Initializes any interface-specific data or routines. (Just calls
- H5F_init() currently).
+ Initializes any interface-specific data or routines.
--------------------------------------------------------------------------*/
-static herr_t
-H5F__init_pub_interface(void)
+herr_t
+H5F__init_package(void)
{
- herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_STATIC
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
/*
* Initialize the atom group for the file IDs.
@@ -110,40 +110,13 @@ H5F__init_pub_interface(void)
if(H5I_register_type(H5I_FILE_CLS) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface")
- ret_value = H5F_init();
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5F__init_pub_interface() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5F_init
- *
- * Purpose: Initialize the interface from some other layer.
- *
- * Return: Success: non-negative
- * Failure: negative
- *
- * Programmer: Robb Matzke
- * Wednesday, December 16, 1998
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5F_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 H5F_init() */
+} /* H5F__init_package() */
/*-------------------------------------------------------------------------
- * Function: H5F_term_interface
+ * Function: H5F_term_package
*
* Purpose: Terminate this interface: free all memory and reset global
* variables to their initial values. Release all ID groups
@@ -161,13 +134,13 @@ done:
*-------------------------------------------------------------------------
*/
int
-H5F_term_interface(void)
+H5F_term_package(void)
{
int n = 0;
FUNC_ENTER_NOAPI_NOINIT_NOERR
- if(H5_interface_initialize_g) {
+ if(H5_PKG_INIT_VAR) {
if(H5I_nmembers(H5I_FILE) > 0) {
(void)H5I_clear_type(H5I_FILE, FALSE, FALSE);
n++; /*H5I*/
@@ -176,20 +149,17 @@ H5F_term_interface(void)
/* Make certain we've cleaned up all the shared file objects */
H5F_sfile_assert_num(0);
- /* Close deprecated interface */
- n += H5F__term_deprec_interface();
-
/* Destroy the file object id group */
- (void)H5I_dec_type_ref(H5I_FILE);
- n++; /*H5I*/
+ n += (H5I_dec_type_ref(H5I_FILE) > 0);
/* Mark closed */
- H5_interface_initialize_g = 0;
+ if(0 == n)
+ H5_PKG_INIT_VAR = FALSE;
} /* end else */
} /* end if */
FUNC_LEAVE_NOAPI(n)
-} /* end H5F_term_interface() */
+} /* end H5F_term_package() */
/*-------------------------------------------------------------------------