summaryrefslogtreecommitdiffstats
path: root/src/H5L.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/H5L.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/H5L.c')
-rw-r--r--src/H5L.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/H5L.c b/src/H5L.c
index 73d363e..a1f3b6e 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -17,10 +17,8 @@
/* Module Setup */
/****************/
-#define H5L_PACKAGE /*suppress error about including H5Lpkg */
+#include "H5Lmodule.h" /* This source code file is part of the H5L module */
-/* Interface initialization */
-#define H5_INTERFACE_INIT_FUNC H5L_init_interface
/***********/
/* Headers */
@@ -191,6 +189,9 @@ static herr_t H5L_get_name_by_idx_cb(H5G_loc_t *grp_loc/*in*/,
/* Package Variables */
/*********************/
+/* Package initialization variable */
+hbool_t H5_PKG_INIT_VAR = FALSE;
+
/*****************************/
/* Library Private Variables */
@@ -235,7 +236,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5L_init_interface
+ * Function: H5L__init_package
*
* Purpose: Initialize information specific to H5L interface.
*
@@ -246,12 +247,12 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5L_init_interface(void)
+herr_t
+H5L__init_package(void)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Initialize user-defined link classes */
if(H5L_register_external() < 0)
@@ -259,13 +260,13 @@ H5L_init_interface(void)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5L_init_interface() */
+} /* end H5L_init_package() */
/*-------------------------------------------------------------------------
- * Function: H5L_term_interface
+ * Function: H5L_term_package
*
- * Purpose: Terminate any resources allocated in H5L_init_interface.
+ * Purpose: Terminate any resources allocated in H5L__init_package.
*
* Return: Non-negative on success/Negative on failure
*
@@ -275,21 +276,27 @@ done:
*-------------------------------------------------------------------------
*/
int
-H5L_term_interface(void)
+H5L_term_package(void)
{
int n = 0;
FUNC_ENTER_NOAPI_NOINIT_NOERR
- /* Free the table of link types */
- H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g);
- H5L_table_used_g = H5L_table_alloc_g = 0;
+ if(H5_PKG_INIT_VAR) {
+ /* Free the table of link types */
+ if(H5L_table_g) {
+ H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g);
+ H5L_table_used_g = H5L_table_alloc_g = 0;
+ n++;
+ } /* end if */
- /* Mark the interface as uninitialized */
- H5_interface_initialize_g = 0;
+ /* Mark the interface as uninitialized */
+ if(0 == n)
+ H5_PKG_INIT_VAR = FALSE;
+ } /* end if */
FUNC_LEAVE_NOAPI(n)
-} /* H5L_term_interface() */
+} /* H5L_term_package() */
/*-------------------------------------------------------------------------
@@ -2756,7 +2763,7 @@ static htri_t
H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id)
{
hbool_t exists = FALSE; /* Whether the link exists in the group */
- htri_t ret_value; /* Return value */
+ htri_t ret_value = FAIL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -2913,7 +2920,7 @@ done:
hid_t
H5L_get_default_lcpl(void)
{
- hid_t ret_value; /* Return value */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_NOAPI(FAIL)