summaryrefslogtreecommitdiffstats
path: root/src/H5FD.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/H5FD.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/H5FD.c')
-rw-r--r--src/H5FD.c76
1 files changed, 22 insertions, 54 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index c4ee11f..bb2d729 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -28,11 +28,8 @@
/* Module Setup */
/****************/
-#define H5F_PACKAGE /*suppress error about including H5Fpkg */
-#define H5FD_PACKAGE /*suppress error about including H5FDpkg */
-
-/* Interface initialization */
-#define H5_INTERFACE_INIT_FUNC H5FD_init_interface
+#define H5F_FRIEND /*suppress error about including H5Fpkg */
+#include "H5FDmodule.h" /* This source code file is part of the H5FD module */
/***********/
@@ -78,6 +75,9 @@ static int H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*o
/* Package Variables */
/*********************/
+/* Package initialization variable */
+hbool_t H5_PKG_INIT_VAR = FALSE;
+
/*****************************/
/* Library Private Variables */
@@ -113,53 +113,24 @@ static const H5I_class_t H5I_VFL_CLS[1] = {{
/*-------------------------------------------------------------------------
- * Function: H5FD_init
- *
- * Purpose: Initialize the interface from some other package.
- *
- * Return: Success: non-negative
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Thursday, January 3, 2007
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5FD_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 H5FD_init() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_init_interface
+ * Function: H5FD__init_package
*
* Purpose: Initialize the virtual file layer.
*
* Return: Success: Non-negative
- *
* Failure: Negative
*
* Programmer: Robb Matzke
* Monday, July 26, 1999
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-static herr_t
-H5FD_init_interface(void)
+herr_t
+H5FD__init_package(void)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
if(H5I_register_type(H5I_VFL_CLS) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize interface")
@@ -169,11 +140,11 @@ H5FD_init_interface(void)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD_init_interface() */
+} /* end H5FD__init_package() */
/*-------------------------------------------------------------------------
- * Function: H5FD_term_interface
+ * Function: H5FD_term_package
*
* Purpose: Terminate this interface: free all memory and reset global
* variables to their initial values. Release all ID groups
@@ -182,40 +153,37 @@ done:
* Return: Success: Positive if anything was done that might
* have affected other interfaces; zero
* otherwise.
- *
* Failure: Never fails.
*
* Programmer: Robb Matzke
* Friday, February 19, 1999
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
-H5FD_term_interface(void)
+H5FD_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_VFL) > 0) {
(void)H5I_clear_type(H5I_VFL, FALSE, FALSE);
n++; /*H5I*/
} /* end if */
else {
/* Destroy the VFL driver id group */
- (void)H5I_dec_type_ref(H5I_VFL);
- n++; /*H5I*/
+ n += (H5I_dec_type_ref(H5I_VFL) > 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 H5FD_term_interface() */
+} /* end H5FD_term_package() */
/*-------------------------------------------------------------------------
@@ -223,7 +191,7 @@ H5FD_term_interface(void)
*
* Purpose: Frees a file driver class struct and returns an indication of
* success. This function is used as the free callback for the
- * virtual file layer object identifiers (cf H5FD_init_interface).
+ * virtual file layer object identifiers (cf H5FD__init_package).
*
* Return: Success: Non-negative
*
@@ -350,7 +318,7 @@ H5FD_register(const void *_cls, size_t size, hbool_t app_ref)
const H5FD_class_t *cls = (const H5FD_class_t *)_cls;
H5FD_class_t *saved = NULL;
H5FD_mem_t type;
- hid_t ret_value;
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -974,7 +942,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
H5P_genplist_t *plist; /* Property list pointer */
unsigned long driver_flags = 0; /* File-inspecific driver feature flags */
H5FD_file_image_info_t file_image_info; /* Initial file image */
- H5FD_t *ret_value; /* Return value */
+ H5FD_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -1189,7 +1157,7 @@ done:
int
H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2)
{
- int ret_value;
+ int ret_value = -1; /* Return value */
FUNC_ENTER_NOAPI(-1) /*return value is arbitrary*/
@@ -1602,7 +1570,7 @@ done:
haddr_t
H5FD_get_maxaddr(const H5FD_t *file)
{
- haddr_t ret_value; /* Return value */
+ haddr_t ret_value = HADDR_UNDEF; /* Return value */
FUNC_ENTER_NOAPI(HADDR_UNDEF)