summaryrefslogtreecommitdiffstats
path: root/src/H5I.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5I.c')
-rw-r--r--src/H5I.c657
1 files changed, 290 insertions, 367 deletions
diff --git a/src/H5I.c b/src/H5I.c
index 3bd9c4d..99f944d 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -28,24 +28,24 @@
#include "H5Imodule.h" /* This source code file is part of the H5I module */
-#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Ipkg.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Oprivate.h" /* Object headers */
-#include "H5SLprivate.h" /* Skip Lists */
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Ipkg.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Oprivate.h" /* Object headers */
+#include "H5SLprivate.h" /* Skip Lists */
/* Define this to compile in support for dumping ID information */
/* #define H5I_DEBUG_OUTPUT */
#ifndef H5I_DEBUG_OUTPUT
-#include "H5Gprivate.h" /* Groups */
+#include "H5Gprivate.h" /* Groups */
#else /* H5I_DEBUG_OUTPUT */
-#define H5G_FRIEND /*suppress error about including H5Gpkg */
-#include "H5Gpkg.h" /* Groups */
-#include "H5Dprivate.h" /* Datasets */
-#include "H5Tprivate.h" /* Datatypes */
+#define H5G_FRIEND /* Suppress error about including H5Gpkg */
+#include "H5Gpkg.h" /* Groups */
+#include "H5Dprivate.h" /* Datasets */
+#include "H5Tprivate.h" /* Datatypes */
#endif /* H5I_DEBUG_OUTPUT */
/* Local Macros */
@@ -186,23 +186,19 @@ H5I_term_package(void)
/*-------------------------------------------------------------------------
- * Function: H5Iregister_type
+ * Function: H5Iregister_type
*
- * Purpose: Public interface to H5I_register_type. Creates a new type
- * of ID's to give out. A specific number (RESERVED) of type
- * entries may be reserved to enable "constant" values to be handed
- * out which are valid IDs in the type, but which do not map to any
- * data structures and are not allocated dynamically later. HASH_SIZE is
- * the minimum hash table size to use for the type. FREE_FUNC is
- * called with an object pointer when the object is removed from
- * the type.
+ * Purpose: Public interface to H5I_register_type. Creates a new type
+ * of ID's to give out. A specific number (RESERVED) of type
+ * entries may be reserved to enable "constant" values to be handed
+ * out which are valid IDs in the type, but which do not map to any
+ * data structures and are not allocated dynamically later. HASH_SIZE is
+ * the minimum hash table size to use for the type. FREE_FUNC is
+ * called with an object pointer when the object is removed from
+ * the type.
*
- * Return: Success: Type ID of the new type
- * Failure: H5I_BADID
- *
- * Programmers: Nathaniel Furrer
- * James Laird
- * Friday, April 30, 2004
+ * Return: Success: Type ID of the new type
+ * Failure: H5I_BADID
*
*-------------------------------------------------------------------------
*/
@@ -270,18 +266,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I_register_type
+ * Function: H5I_register_type
*
- * Purpose: Creates a new type of ID's to give out.
- * The class is initialized or its reference count is incremented
+ * Purpose: Creates a new type of ID's to give out.
+ * The class is initialized or its reference count is incremented
* (if it is already initialized).
*
- * Return: Success: Type ID of the new type
- * Failure: H5I_BADID
- *
- * Programmers: Nathaniel Furrer
- * James Laird
- * Friday, April 30, 2004
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -335,17 +326,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Itype_exists
+ * Function: H5Itype_exists
*
* Purpose: Query function to inform the user if a given type is
* currently registered with the library.
*
- * Return: Success: 1 if the type is registered, 0 if it is not
- * Failure: Negative
- *
- * Programmer: James Laird
- * Nathaniel Furrer
- * Tuesday, June 29, 2004
+ * Return: Success: 1 if the type is registered, 0 if it is not
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -357,10 +344,10 @@ H5Itype_exists(H5I_type_t type)
FUNC_ENTER_API(FAIL)
H5TRACE1("t", "It", type);
- if(type <= H5I_BADID || type >= H5I_next_type)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
+ if (type <= H5I_BADID || type >= H5I_next_type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
- if(NULL == H5I_id_type_list_g[type])
+ if (NULL == H5I_id_type_list_g[type])
ret_value = FALSE;
done:
@@ -401,9 +388,9 @@ H5Inmembers(H5I_type_t type, hsize_t *num_members)
* an error when the supplied type does not exist.
*/
if(type <= H5I_BADID || type >= H5I_next_type)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
if(NULL == H5I_id_type_list_g[type])
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "supplied type does not exist")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "supplied type does not exist")
if(num_members) {
int64_t members;
@@ -685,15 +672,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Iregister
+ * Function: H5Iregister
*
- * Purpose: Public interface to H5I_register.
+ * Purpose: Public interface to H5I_register.
*
- * Return: Success: New object id.
- * Failure: Negative
- *
- * Programmer: Nathaniel Furrer
- * James Laird
+ * Return: Success: New object id.
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -727,7 +711,7 @@ done:
* the ID which is returned to the user.
*
* Return: Success: New object id
- * Failure: Negative
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
@@ -737,18 +721,18 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref)
H5I_id_type_t *type_ptr = NULL; /* ptr to the type */
H5I_id_info_t *id_ptr = NULL; /* ptr to the new ID information */
hid_t new_id = -1; /* new ID */
- hid_t ret_value = SUCCEED; /* return value */
+ hid_t ret_value = H5I_INVALID_HID; /* return value */
FUNC_ENTER_NOAPI(FAIL)
/* Check arguments */
if (type <= H5I_BADID || type >= H5I_next_type)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number")
type_ptr = H5I_id_type_list_g[type];
if ((NULL == type_ptr) || (type_ptr->init_count <= 0))
- HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type")
+ HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, H5I_INVALID_HID, "invalid type")
if (NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t)))
- HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed")
+ HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed")
/* Create the struct & its ID */
new_id = H5I_MAKE(type, type_ptr->nextid);
@@ -759,7 +743,7 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref)
/* Insert into the type */
if (H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, FAIL, "can't insert ID node into skip list")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert ID node into skip list")
type_ptr->id_count++;
type_ptr->nextid++;
@@ -777,27 +761,23 @@ done:
/*-------------------------------------------------------------------------
* Function: H5I_register_with_id
*
- * Purpose: Registers an OBJECT in a TYPE with the supplied ID for it.
- * This routine will check to ensure the supplied ID is not already
- * in use, and ensure that it is a valid ID for the given type,
- * but will NOT check to ensure the OBJECT is not already
- * registered (thus, it is possible to register one object under
- * multiple IDs).
- *
- * Return: Success: 0
- * Failure: -1
+ * Purpose: Registers an OBJECT in a TYPE with the supplied ID for it.
+ * This routine will check to ensure the supplied ID is not already
+ * in use, and ensure that it is a valid ID for the given type,
+ * but will NOT check to ensure the OBJECT is not already
+ * registered (thus, it is possible to register one object under
+ * multiple IDs).
*
- * Programmer: Mike McGreevy
- * Wednesday, July 21, 2010
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t id)
{
- H5I_id_type_t *type_ptr; /*ptr to the type */
- H5I_id_info_t *id_ptr; /*ptr to the new ID information */
- herr_t ret_value = SUCCEED; /*return value */
+ H5I_id_type_t *type_ptr; /* ptr to the type */
+ H5I_id_info_t *id_ptr; /* ptr to the new ID information */
+ herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1187,10 +1167,10 @@ H5I_remove(hid_t id)
/* Check arguments */
type = H5I_TYPE(id);
if(type <= H5I_BADID || type >= H5I_next_type)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number")
type_ptr = H5I_id_type_list_g[type];
if(type_ptr == NULL || type_ptr->init_count <= 0)
- HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type")
+ HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type")
/* Remove the node from the type */
if(NULL == (ret_value = H5I__remove_common(type_ptr, id)))
@@ -1226,7 +1206,7 @@ H5Idec_ref(hid_t id)
/* Check arguments */
if(id < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID")
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID")
/* Do actual decrement operation */
if((ret_value = H5I_dec_app_ref(id)) < 0)
@@ -1359,16 +1339,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I_dec_app_ref_always_close
+ * Function: H5I_dec_app_ref_always_close
*
- * Purpose: H5I_dec_app_ref wrapper for case of always closing the ID,
- * even when the free routine fails
+ * Purpose: H5I_dec_app_ref wrapper for case of always closing the ID,
+ * even when the free routine fails
*
- * Return: Success: New app. reference count.
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * Sept 16, 2010
+ * Return: Success: New app. reference count.
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1386,7 +1363,7 @@ H5I_dec_app_ref_always_close(hid_t id)
ret_value = H5I_dec_app_ref(id);
/* Check for failure */
- if(ret_value < 0) {
+ if (ret_value < 0) {
/*
* If an object is closing, we can remove the ID even though the free
* method might fail. This can happen when a mandatory filter fails to
@@ -1396,7 +1373,7 @@ H5I_dec_app_ref_always_close(hid_t id)
H5I_remove(id);
HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count")
- } /* end if */
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1404,15 +1381,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Iinc_ref
- *
- * Purpose: Increments the number of references outstanding for an ID.
+ * Function: H5Iinc_ref
*
- * Return: Success: New reference count
- * Failure: Negative
+ * Purpose: Increments the number of references outstanding for an ID.
*
- * Programmer: Quincey Koziol
- * Dec 7, 2003
+ * Return: Success: New reference count
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1425,11 +1399,11 @@ H5Iinc_ref(hid_t id)
H5TRACE1("Is", "i", id);
/* Check arguments */
- if(id < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID")
+ if (id < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID")
/* Do actual increment operation */
- if((ret_value = H5I_inc_ref(id, TRUE)) < 0)
+ if ((ret_value = H5I_inc_ref(id, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count")
done:
@@ -1438,15 +1412,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I_inc_ref
+ * Function: H5I_inc_ref
*
- * Purpose: Increment the reference count for an object.
+ * Purpose: Increment the reference count for an object.
*
- * Return: Success: The new reference count.
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * Thursday, July 29, 1999
+ * Return: Success: The new reference count.
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1462,8 +1433,8 @@ H5I_inc_ref(hid_t id, hbool_t app_ref)
HDassert(id >= 0);
/* General lookup of the ID */
- if(NULL == (id_ptr = H5I__find_id(id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID")
+ if (NULL == (id_ptr = H5I__find_id(id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID")
/* Adjust reference counts */
++(id_ptr->count);
@@ -1479,15 +1450,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Iget_ref
+ * Function: H5Iget_ref
*
- * Purpose: Retrieves the number of references outstanding for an ID.
- *
- * Return: Success: Reference count
- * Failure: Negative
+ * Purpose: Retrieves the number of references outstanding for an ID.
*
- * Programmer: Quincey Koziol
- * Dec 7, 2003
+ * Return: Success: Reference count
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1500,11 +1468,11 @@ H5Iget_ref(hid_t id)
H5TRACE1("Is", "i", id);
/* Check arguments */
- if(id < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID")
+ if (id < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID")
/* Do actual retrieve operation */
- if((ret_value = H5I_get_ref(id, TRUE)) < 0)
+ if ((ret_value = H5I_get_ref(id, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count")
done:
@@ -1513,15 +1481,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I_get_ref
+ * Function: H5I_get_ref
*
- * Purpose: Retrieve the reference count for an object.
+ * Purpose: Retrieve the reference count for an object.
*
- * Return: Success: The reference count.
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * Saturday, Decemeber 6, 2003
+ * Return: Success: The reference count.
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1537,8 +1502,8 @@ H5I_get_ref(hid_t id, hbool_t app_ref)
HDassert(id >= 0);
/* General lookup of the ID */
- if(NULL == (id_ptr = H5I__find_id(id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID")
+ if (NULL == (id_ptr = H5I__find_id(id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID")
/* Set return value */
ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count);
@@ -1549,16 +1514,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Iinc_type_ref
+ * Function: H5Iinc_type_ref
*
- * Purpose: Increments the number of references outstanding for an ID type.
+ * Purpose: Increments the number of references outstanding for an ID type.
*
- * Return: Success: New reference count
- * Failure: Negative
- *
- * Programmer: Nat Furrer
- * James Laird
- * April 30, 2004
+ * Return: Success: New reference count
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1571,14 +1532,14 @@ H5Iinc_type_ref(H5I_type_t type)
H5TRACE1("Is", "It", type);
/* Check arguments */
- if(type <= 0 || type >= H5I_next_type)
+ if (type <= 0 || type >= H5I_next_type)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID type")
- if(H5I_IS_LIB_TYPE(type))
+ if (H5I_IS_LIB_TYPE(type))
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type")
/* Do actual increment operation */
- if((ret_value = H5I__inc_type_ref(type)) < 0)
+ if ((ret_value = H5I__inc_type_ref(type)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID type ref count")
done:
@@ -1587,16 +1548,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I__inc_type_ref
+ * Function: H5I__inc_type_ref
*
- * Purpose: Increment the reference count for an ID type.
+ * Purpose: Increment the reference count for an ID type.
*
- * Return: Success: The new reference count.
- * Failure: Negative
- *
- * Programmer: James Laird
- * Nat Furrer
- * Friday, April 30, 2004
+ * Return: Success: The new reference count
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1613,8 +1570,8 @@ H5I__inc_type_ref(H5I_type_t type)
/* Check arguments */
type_ptr = H5I_id_type_list_g[type];
- if(!type_ptr)
- HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type")
+ if (!type_ptr)
+ HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type")
/* Set return value */
ret_value = (int)(++(type_ptr->init_count));
@@ -1625,24 +1582,26 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Idec_type_ref
- *
- * Purpose: Decrements the reference count on an entire type of IDs.
- * If the type reference count becomes zero then the type is
- * destroyed along with all atoms in that type regardless of
- * their reference counts. Destroying IDs involves calling
- * the free-func for each ID's object and then adding the ID
- * struct to the ID free list. Public interface to
- * H5I_dec_type_ref.
- * Returns the number of references to the type on success; a
- * return value of 0 means that the type will have to be
- * re-initialized before it can be used again (and should probably
- * be set to H5I_UNINIT).
- *
- * Return: Number of references to type on success/Negative on failure
- *
- * Programmer: Nathaniel Furrer
- * James Laird
+ * Function: H5Idec_type_ref
+ *
+ * Purpose: Decrements the reference count on an entire type of IDs.
+ * If the type reference count becomes zero then the type is
+ * destroyed along with all atoms in that type regardless of
+ * their reference counts. Destroying IDs involves calling
+ * the free-func for each ID's object and then adding the ID
+ * struct to the ID free list. Public interface to
+ * H5I_dec_type_ref.
+ * Returns the number of references to the type on success; a
+ * return value of 0 means that the type will have to be
+ * re-initialized before it can be used again (and should probably
+ * be set to H5I_UNINIT).
+ *
+ * NOTE: Using an error type to also represent a count is semantially
+ * incorrect. We should consider fixing this in a future major
+ * release (DER).
+ *
+ * Return: Success: Number of references to type
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1654,7 +1613,7 @@ H5Idec_type_ref(H5I_type_t type)
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "It", type);
- if(H5I_IS_LIB_TYPE(type))
+ if (H5I_IS_LIB_TYPE(type))
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type")
ret_value = H5I_dec_type_ref(type);
@@ -1665,22 +1624,21 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I_dec_type_ref
- *
- * Purpose: Decrements the reference count on an entire type of IDs.
- * If the type reference count becomes zero then the type is
- * destroyed along with all atoms in that type regardless of
- * their reference counts. Destroying IDs involves calling
- * the free-func for each ID's object and then adding the ID
- * struct to the ID free list.
- * Returns the number of references to the type on success; a
- * return value of 0 means that the type will have to be
- * re-initialized before it can be used again (and should probably
- * be set to H5I_UNINIT).
- *
- * Return: Number of references to type on success/Negative on failure
- *
- * Programmer: Unknown
+ * Function: H5I_dec_type_ref
+ *
+ * Purpose: Decrements the reference count on an entire type of IDs.
+ * If the type reference count becomes zero then the type is
+ * destroyed along with all atoms in that type regardless of
+ * their reference counts. Destroying IDs involves calling
+ * the free-func for each ID's object and then adding the ID
+ * struct to the ID free list.
+ * Returns the number of references to the type on success; a
+ * return value of 0 means that the type will have to be
+ * re-initialized before it can be used again (and should probably
+ * be set to H5I_UNINIT).
+ *
+ * Return: Success: Number of references to type
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1692,27 +1650,26 @@ H5I_dec_type_ref(H5I_type_t type)
FUNC_ENTER_NOAPI(FAIL)
- if(type <= H5I_BADID || type >= H5I_next_type)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
+ if (type <= H5I_BADID || type >= H5I_next_type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
type_ptr = H5I_id_type_list_g[type];
- if(type_ptr == NULL || type_ptr->init_count <= 0)
- HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type")
+ if (type_ptr == NULL || type_ptr->init_count <= 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type")
- /*
- * Decrement the number of users of the atomic type. If this is the
+ /* Decrement the number of users of the atomic type. If this is the
* last user of the type then release all atoms from the type and
* free all memory it used. The free function is invoked for each atom
* being freed.
*/
- if(1 == type_ptr->init_count) {
+ if (1 == type_ptr->init_count) {
H5I__destroy_type(type);
ret_value = 0;
- } /* end if */
+ }
else {
--(type_ptr->init_count);
ret_value = (herr_t)type_ptr->init_count;
- } /* end else */
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1720,16 +1677,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Iget_type_ref
+ * Function: H5Iget_type_ref
*
- * Purpose: Retrieves the number of references outstanding for a type.
- *
- * Return: Success: Reference count
- * Failure: Negative
+ * Purpose: Retrieves the number of references outstanding for a type.
*
- * Programmer: Nat Furrer
- * James Laird
- * April 30, 2004
+ * Return: Success: Reference count
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1742,14 +1695,14 @@ H5Iget_type_ref(H5I_type_t type)
H5TRACE1("Is", "It", type);
/* Check arguments */
- if(type <= 0 || type >= H5I_next_type)
+ if (type <= 0 || type >= H5I_next_type)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID type")
- if(H5I_IS_LIB_TYPE(type))
+ if (H5I_IS_LIB_TYPE(type))
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type")
/* Do actual retrieve operation */
- if((ret_value = H5I__get_type_ref(type)) < 0)
+ if ((ret_value = H5I__get_type_ref(type)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID type ref count")
done:
@@ -1758,25 +1711,21 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I__get_type_ref
+ * Function: H5I__get_type_ref
*
- * Purpose: Retrieve the reference count for an ID type.
+ * Purpose: Retrieve the reference count for an ID type.
*
- * Return: Success: The reference count.
+ * Return: Success: The reference count.
*
- * Failure: Negative
- *
- * Programmer: Nat Furrer
- * James Laird
- * April 30, 2004
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
static int
H5I__get_type_ref(H5I_type_t type)
{
- H5I_id_type_t *type_ptr; /*ptr to the type */
- int ret_value = -1; /* Return value */
+ H5I_id_type_t *type_ptr; /* Pointer to the type */
+ int ret_value = -1; /* Return value */
FUNC_ENTER_STATIC
@@ -1785,7 +1734,7 @@ H5I__get_type_ref(H5I_type_t type)
/* Check arguments */
type_ptr = H5I_id_type_list_g[type];
- if(!type_ptr)
+ if (!type_ptr)
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type")
/* Set return value */
@@ -1797,17 +1746,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Iis_valid
+ * Function: H5Iis_valid
*
- * Purpose: Check if the given id is valid. An id is valid if it is in
+ * Purpose: Check if the given id is valid. An id is valid if it is in
* use and has an application reference count of at least 1.
*
- * Return: Success: TRUE if the id is valid, FALSE otherwise.
- *
- * Failure: Negative (never fails currently)
+ * Return: Success: TRUE if the id is valid, FALSE otherwise.
*
- * Programmer: Neil Fortner
- * Friday, October 31, 2008 (boo)
+ * Failure: Negative (never fails currently)
*
*-------------------------------------------------------------------------
*/
@@ -1823,9 +1769,7 @@ H5Iis_valid(hid_t id)
/* Find the ID */
if (NULL == (id_ptr = H5I__find_id(id)))
ret_value = FALSE;
-
- /* Check if the found id is an internal id */
- else if (!id_ptr->app_count)
+ else if (!id_ptr->app_count) /* Check if the found id is an internal id */
ret_value = FALSE;
done:
@@ -1834,19 +1778,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I__search_cb
+ * Function: H5I__search_cb
*
- * Purpose: Callback routine for H5Isearch, when it calls H5I_iterate.
- * Calls "user" callback search function, and then sets return
- * value, based on the result of that callback.
- *
- * Return: Success: The first object in the type for which FUNC
- * returns non-zero. NULL if FUNC returned zero
- * for every object in the type.
- * Failure: NULL
+ * Purpose: Callback routine for H5Isearch, when it calls H5I_iterate.
+ * Calls "user" callback search function, and then sets return
+ * value, based on the result of that callback.
*
- * Programmer: Quincey Koziol
- * Friday, March 30, 2012
+ * Return: Success: The first object in the type for which FUNC
+ * returns non-zero. NULL if FUNC returned zero
+ * for every object in the type.
+ * Failure: NULL
*
*-------------------------------------------------------------------------
*/
@@ -1859,7 +1800,7 @@ H5I__search_cb(void *obj, hid_t id, void *_udata)
FUNC_ENTER_STATIC_NOERR
ret_value = (*udata->app_cb)(obj, id, udata->app_key);
- if(ret_value > 0)
+ if (ret_value > 0)
udata->ret_obj = obj;
FUNC_LEAVE_NOAPI(ret_value)
@@ -1867,26 +1808,22 @@ H5I__search_cb(void *obj, hid_t id, void *_udata)
/*-------------------------------------------------------------------------
- * Function: H5Isearch
+ * Function: H5Isearch
*
- * Purpose: Apply function FUNC to each member of type TYPE and return a
- * pointer to the first object for which FUNC returns non-zero.
- * The FUNC should take a pointer to the object and the KEY as
- * arguments and return non-zero to terminate the search (zero
- * to continue). Public interface to H5I_search.
+ * Purpose: Apply function FUNC to each member of type TYPE and return a
+ * pointer to the first object for which FUNC returns non-zero.
+ * The FUNC should take a pointer to the object and the KEY as
+ * arguments and return non-zero to terminate the search (zero
+ * to continue). Public interface to H5I_search.
*
- * Limitation: Currently there is no way to start searching from where a
- * previous search left off.
+ * Limitation: Currently there is no way to start searching from where a
+ * previous search left off.
*
- * Return: Success: The first object in the type for which FUNC
- * returns non-zero. NULL if FUNC returned zero
- * for every object in the type.
+ * Return: Success: The first object in the type for which FUNC
+ * returns non-zero. NULL if FUNC returned zero
+ * for every object in the type.
*
- * Failure: NULL
- *
- * Programmer: James Laird
- * Nathaniel Furrer
- * Friday, April 23, 2004
+ * Failure: NULL
*
*-------------------------------------------------------------------------
*/
@@ -1900,7 +1837,7 @@ H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key)
H5TRACE3("*x", "Itx*x", type, func, key);
/* Check arguments */
- if(H5I_IS_LIB_TYPE(type))
+ if (H5I_IS_LIB_TYPE(type))
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type")
/* Set up udata struct */
@@ -1922,17 +1859,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I__iterate_cb
+ * Function: H5I__iterate_cb
*
- * Purpose: Callback routine for H5I_iterate, invokes "user" callback
+ * Purpose: Callback routine for H5I_iterate, invokes "user" callback
* function, and then sets return value, based on the result of
* that callback.
*
- * Return: Success: Non-negative on success
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * Thursday, October 3, 2013
+ * Return: Success: Non-negative on success
+ * Failure: Negative
*
*-------------------------------------------------------------------------
*/
@@ -1964,29 +1898,25 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
/*-------------------------------------------------------------------------
* Function: H5I_iterate
*
- * Purpose: Apply function FUNC to each member of type TYPE (with
- * non-zero application reference count if app_ref is TRUE).
- * Stop if FUNC returns a non zero value (i.e. anything
- * other than H5_ITER_CONT).
+ * Purpose: Apply function FUNC to each member of type TYPE (with
+ * non-zero application reference count if app_ref is TRUE).
+ * Stop if FUNC returns a non zero value (i.e. anything
+ * other than H5_ITER_CONT).
*
- * If FUNC returns a positive value (i.e. H5_ITER_STOP),
- * return SUCCEED.
+ * If FUNC returns a positive value (i.e. H5_ITER_STOP),
+ * return SUCCEED.
*
- * If FUNC returns a negative value (i.e. H5_ITER_ERROR),
- * return FAIL.
+ * If FUNC returns a negative value (i.e. H5_ITER_ERROR),
+ * return FAIL.
*
- * The FUNC should take a pointer to the object and the
- * udata as arguments and return non-zero to terminate
- * siteration, and zero to continue.
+ * The FUNC should take a pointer to the object and the
+ * udata as arguments and return non-zero to terminate
+ * siteration, and zero to continue.
*
- * Limitation: Currently there is no way to start the iteration from
- * where a previous iteration left off.
+ * Limitation: Currently there is no way to start the iteration from
+ * where a previous iteration left off.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
- *
- * Programmer: John Mainzer
- * Monday, December 6, 2011
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1999,12 +1929,12 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re
FUNC_ENTER_NOAPI(FAIL)
/* Check arguments */
- if(type <= H5I_BADID || type >= H5I_next_type)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
+ if (type <= H5I_BADID || type >= H5I_next_type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
type_ptr = H5I_id_type_list_g[type];
/* Only iterate through ID list if it is initialized and there are IDs in type */
- if(type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) {
+ if (type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) {
H5I_iterate_ud_t iter_udata; /* User data for iteration callback */
herr_t iter_status; /* Iteration status */
@@ -2014,9 +1944,9 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re
iter_udata.app_ref = app_ref;
/* Iterate over IDs */
- if((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0)
+ if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed")
- } /* end if */
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2024,16 +1954,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I__find_id
- *
- * Purpose: Given an object ID find the info struct that describes the
- * object.
+ * Function: H5I__find_id
*
- * Return: Success: Ptr to the object's info struct.
+ * Purpose: Given an object ID find the info struct that describes the
+ * object.
*
- * Failure: NULL
+ * Return: Success: A pointer to the object's info struct.
*
- * Programmer: Unknown
+ * Failure: NULL
*
*-------------------------------------------------------------------------
*/
@@ -2048,12 +1976,12 @@ H5I__find_id(hid_t id)
/* Check arguments */
type = H5I_TYPE(id);
- if(type <= H5I_BADID || type >= H5I_next_type)
- HGOTO_DONE(NULL)
+ if (type <= H5I_BADID || type >= H5I_next_type)
+ HGOTO_DONE(NULL)
type_ptr = H5I_id_type_list_g[type];
- if(!type_ptr || type_ptr->init_count <= 0)
- HGOTO_DONE(NULL)
+ if (!type_ptr || type_ptr->init_count <= 0)
+ HGOTO_DONE(NULL)
/* Locate the ID node for the ID */
ret_value = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id);
@@ -2064,17 +1992,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Iget_name
- *
- * Purpose: Gets a name of an object from its ID.
+ * Function: H5Iget_name
*
- * Return: Success: The length of name.
+ * Purpose: Gets a name of an object from its ID.
*
- * Failure: -1
+ * Return: Success: The length of the name
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: July 26, 2002
+ * Failure: -1
*
* Comments: Public function
* If `name' is non-NULL then write up to `size' bytes into that
@@ -2098,12 +2022,12 @@ H5Iget_name(hid_t id, char *name/*out*/, size_t size)
H5TRACE3("Zs", "ixz", id, name, size);
/* Get object location */
- if(H5G_loc(id, &loc) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object location")
+ if (H5G_loc(id, &loc) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object location")
/* Call internal group routine to retrieve object's name */
- if((ret_value = H5G_get_name(&loc, name, size, NULL, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name")
+ if ((ret_value = H5G_get_name(&loc, name, size, NULL, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name")
done:
FUNC_LEAVE_API(ret_value)
@@ -2111,30 +2035,27 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Iget_file_id
+ * Function: H5Iget_file_id
*
- * Purpose: The public version of H5I_get_file_id(), obtains the file
+ * Purpose: The public version of H5I_get_file_id(), obtains the file
* ID given an object ID. User has to close this ID.
*
- * Return: Success: file ID
- *
- * Failure: a negative value
+ * Return: Success: The file ID associated with the object
*
- * Programmer: Raymond Lu
- * Oct 27, 2003
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5Iget_file_id(hid_t obj_id)
{
- hid_t ret_value; /* Return value */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", obj_id);
- if((ret_value = H5I_get_file_id(obj_id, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID")
+ if ((ret_value = H5I_get_file_id(obj_id, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID")
done:
FUNC_LEAVE_API(ret_value)
@@ -2142,50 +2063,48 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I_get_file_id
+ * Function: H5I_get_file_id
*
- * Purpose: The private version of H5Iget_file_id(), obtains the file
+ * Purpose: The private version of H5Iget_file_id(), obtains the file
* ID given an object ID.
*
- * Return: Success: file ID
- * Failure: a negative value
+ * Return: Success: The file ID associated with the object
*
- * Programmer: Raymond Lu
- * Oct 27, 2003
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5I_get_file_id(hid_t obj_id, hbool_t app_ref)
{
- H5I_type_t type; /* ID type */
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
+ H5I_type_t type; /* ID type */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Get object type */
type = H5I_TYPE(obj_id);
- if(type == H5I_FILE) {
+ if (type == H5I_FILE) {
/* Increment reference count on file ID */
if(H5I_inc_ref(obj_id, app_ref) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed")
/* Set return value */
ret_value = obj_id;
- } /* end if */
- else if(type == H5I_DATATYPE || type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) {
+ }
+ else if (type == H5I_DATATYPE || type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) {
H5G_loc_t loc; /* Location of object */
/* Get the object location information */
if(H5G_loc(obj_id, &loc) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get object location")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get object location")
/* Get the file ID for the object */
if((ret_value = H5F_get_id(loc.oloc->file, app_ref)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get file ID")
- } /* end if */
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID")
+ }
else
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid object ID")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2194,34 +2113,29 @@ done:
#ifdef H5I_DEBUG_OUTPUT
/*-------------------------------------------------------------------------
- * Function: H5I__debug_cb
+ * Function: H5I__debug_cb
*
- * Purpose: Dump the contents of an ID to stderr for debugging.
+ * Purpose: Dump the contents of an ID to stderr for debugging.
*
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * Friday, February 19, 1999
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
{
- H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */
- H5I_type_t type = *(H5I_type_t *)_udata; /* User data */
- H5G_name_t *path = NULL;
- int ret_value = H5_ITER_CONT; /* Return value */
+ H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */
+ H5I_type_t type = *(H5I_type_t *)_udata; /* User data */
+ H5G_name_t *path = NULL;
FUNC_ENTER_STATIC_NOERR
- fprintf(stderr, " id = %lu\n", (unsigned long)(item->id));
- fprintf(stderr, " count = %u\n", item->count);
- fprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(item->obj_ptr));
+ HDfprintf(stderr, " id = %lu\n", (unsigned long)(item->id));
+ HDfprintf(stderr, " count = %u\n", item->count);
+ HDfprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(item->obj_ptr));
/* Get the group location, so we get get the name */
- switch(type) {
+ switch (type) {
case H5I_GROUP:
path = H5G_nameof((H5G_t*)item->obj_ptr);
break;
@@ -2234,31 +2148,40 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
path = H5T_nameof((H5T_t*)item->obj_ptr);
break;
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_FILE:
+ case H5I_DATASPACE:
+ case H5I_ATTR:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
default:
break; /* Other types of IDs are not stored in files */
- } /* end switch*/
+ }
- if(path) {
- if(path->user_path_r)
- fprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r));
- if(path->full_path_r)
- fprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r));
- } /* end if */
+ if (path) {
+ if (path->user_path_r)
+ HDfprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r));
+ if (path->full_path_r)
+ HDfprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r));
+ }
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5I__debug_cb() */
/*-------------------------------------------------------------------------
- * Function: H5I__debug
- *
- * Purpose: Dump the contents of a type to stderr for debugging.
+ * Function: H5I__debug
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Purpose: Dump the contents of a type to stderr for debugging.
*
- * Programmer: Robb Matzke
- * Friday, February 19, 1999
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -2269,17 +2192,17 @@ H5I__debug(H5I_type_t type)
FUNC_ENTER_STATIC_NOERR
- fprintf(stderr, "Dumping ID type %d\n", (int)type);
+ HDfprintf(stderr, "Dumping ID type %d\n", (int)type);
type_ptr = H5I_id_type_list_g[type];
/* Header */
- fprintf(stderr, " init_count = %u\n", type_ptr->init_count);
- fprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved);
- fprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count);
- fprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid);
+ HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count);
+ HDfprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved);
+ HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count);
+ HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid);
/* List */
- fprintf(stderr, " List:\n");
+ HDfprintf(stderr, " List:\n");
H5SL_iterate(type_ptr->ids, H5I__debug_cb, &type);
FUNC_LEAVE_NOAPI(SUCCEED)