summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2008-11-17 19:13:08 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2008-11-17 19:13:08 (GMT)
commite00d3174e587025a1090362f510aa5d6cf67b304 (patch)
tree528c19883933534b67ecf2535558c44124e95e1b /src
parenta6493ad0c094fdfbc3068502a9b7a39fc3f450cc (diff)
downloadhdf5-e00d3174e587025a1090362f510aa5d6cf67b304.zip
hdf5-e00d3174e587025a1090362f510aa5d6cf67b304.tar.gz
hdf5-e00d3174e587025a1090362f510aa5d6cf67b304.tar.bz2
[svn-r16086] Purpose: Port H5Iis_valid function to 1.8 branch
Tested: kagiso (trunk version tested with h5committest)
Diffstat (limited to 'src')
-rw-r--r--src/H5I.c47
-rw-r--r--src/H5Ipublic.h1
2 files changed, 48 insertions, 0 deletions
diff --git a/src/H5I.c b/src/H5I.c
index 40fec88..f29624b 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -1844,6 +1844,53 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Iis_valid
+ *
+ * Purpose: Check if the given id is valid. And 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)
+ *
+ * Programmer: Neil Fortner
+ * Friday, October 31, 2008 (boo)
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5Iis_valid(hid_t id)
+{
+ H5I_id_type_t *type_ptr; /* ptr to ID's type */
+ H5I_id_info_t *id_ptr; /* ptr to the ID */
+ H5I_type_t type; /* ID's type */
+ htri_t ret_value = TRUE; /* Return value */
+
+ FUNC_ENTER_API(H5Iis_valid, FAIL)
+
+ type = H5I_TYPE(id);
+ /* Check for conditions that would cause H5I_find_id to throw an assertion */
+ if (type <= H5I_BADID || type >= H5I_next_type)
+ HGOTO_DONE(FALSE);
+
+ type_ptr = H5I_id_type_list_g[type];
+ if (!type_ptr || type_ptr->count <= 0)
+ ret_value = FALSE;
+
+ /* Find the ID */
+ else 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)
+ ret_value = FALSE;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Iis_valid() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Isearch
*
* Purpose: Apply function FUNC to each member of type TYPE and return a
diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h
index 108f040..608bc9c 100644
--- a/src/H5Ipublic.h
+++ b/src/H5Ipublic.h
@@ -95,6 +95,7 @@ H5_DLL int H5Iget_type_ref(H5I_type_t type);
H5_DLL void *H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key);
H5_DLL herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members);
H5_DLL htri_t H5Itype_exists(H5I_type_t type);
+H5_DLL htri_t H5Iis_valid(hid_t id);
#ifdef __cplusplus
}