summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-10-29 18:27:37 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-10-29 18:27:37 (GMT)
commitbbe23c026f974be06e2aa86cff55cd255b33e2d0 (patch)
treeed03d4462f7477ce9b3710f8fcda146c17c561b1 /src
parent8b45b9a5f0305b6f881f25a8a7649fb67decca0f (diff)
downloadhdf5-bbe23c026f974be06e2aa86cff55cd255b33e2d0.zip
hdf5-bbe23c026f974be06e2aa86cff55cd255b33e2d0.tar.gz
hdf5-bbe23c026f974be06e2aa86cff55cd255b33e2d0.tar.bz2
[svn-r7786] Purpose:
Code cleanup & add a feature Description: Added support for querying the file ID of named datatypes to new H5Iget_file_id function. Platforms tested: FreeBSD 4.9 (sleipnir) too minor to require h5committest
Diffstat (limited to 'src')
-rw-r--r--src/H5F.c1
-rw-r--r--src/H5Gprivate.h1
-rw-r--r--src/H5I.c40
-rw-r--r--src/H5Iprivate.h1
4 files changed, 22 insertions, 21 deletions
diff --git a/src/H5F.c b/src/H5F.c
index dd9a3d6..b095ace 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -4191,7 +4191,6 @@ H5F_get_id(H5F_t *file)
assert(file);
ret_value = file->file_id;
-done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_get_id() */
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index b2bff6c..2bf2c3f 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -38,7 +38,6 @@
#include "H5private.h" /* Generic Functions */
#include "H5Bprivate.h" /* B-trees */
#include "H5Fprivate.h" /* File access */
-#include "H5Gprivate.h" /* Group */
#include "H5RSprivate.h" /* Reference-counted strings */
/*
diff --git a/src/H5I.c b/src/H5I.c
index 627b605..4af50a1 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -117,6 +117,7 @@ H5FL_DEFINE_STATIC(H5I_id_info_t);
/*--------------------- Local function prototypes ---------------------------*/
static herr_t H5I_init_interface(void);
static H5I_id_info_t *H5I_find_id(hid_t id);
+static hid_t H5I_get_file_id(hid_t obj_id);
#ifdef H5I_DEBUG_OUTPUT
static herr_t H5I_debug(H5I_type_t grp);
#endif /* H5I_DEBUG_OUTPUT */
@@ -812,12 +813,13 @@ done:
hid_t
H5Iget_file_id(hid_t obj_id)
{
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Iget_file_id, FAIL);
H5TRACE1("i","i",obj_id);
- ret_value = H5I_get_file_id(obj_id);
+ if((ret_value = H5I_get_file_id(obj_id))<0)
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID");
done:
FUNC_LEAVE_API(ret_value);
@@ -841,39 +843,41 @@ done:
*
*-------------------------------------------------------------------------
*/
-hid_t
+static hid_t
H5I_get_file_id(hid_t obj_id)
{
- hid_t ret_value = FAIL;
- H5I_type_t obj_type = H5I_BADID;
H5G_entry_t *ent;
+ hid_t ret_value;
- FUNC_ENTER_NOAPI(H5I_get_file_id, FAIL);
+ FUNC_ENTER_NOINIT(H5I_get_file_id);
/* Get object type */
- obj_type = H5I_GRP(obj_id);
-
- switch(obj_type) {
+ switch(H5I_GRP(obj_id)) {
case H5I_FILE:
ret_value = obj_id;
- /* Increment reference count on atom. */
- if (H5I_inc_ref(ret_value)<0)
- HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "incrementing file ID failed");
-
break;
+
+ case H5I_DATATYPE:
+ if((ent = H5G_loc(obj_id))==NULL)
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "not a named datatype");
+ ret_value = H5F_get_id(ent->file);
+ break;
+
case H5I_GROUP:
case H5I_DATASET:
case H5I_ATTR:
- ent = H5G_loc(obj_id);
+ if((ent = H5G_loc(obj_id))==NULL)
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "can't get symbol table info");
ret_value = H5F_get_id(ent->file);
- /* Increment reference count on atom. */
- if (H5I_inc_ref(ret_value)<0)
- HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "incrementing file ID failed");
-
break;
+
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID");
}
+
+ /* Increment reference count on atom. */
+ if (H5I_inc_ref(ret_value)<0)
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed");
done:
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h
index 42369e3..79819a5 100644
--- a/src/H5Iprivate.h
+++ b/src/H5Iprivate.h
@@ -67,7 +67,6 @@ H5_DLL hid_t H5I_register(H5I_type_t grp, void *object);
H5_DLL void *H5I_object(hid_t id);
H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type);
H5_DLL H5I_type_t H5I_get_type(hid_t id);
-H5_DLL hid_t H5I_get_file_id(hid_t obj_id);
H5_DLL void *H5I_remove(hid_t id);
H5_DLL void *H5I_search(H5I_type_t grp, H5I_search_func_t func, void *key);
H5_DLL int H5I_inc_ref(hid_t id);