summaryrefslogtreecommitdiffstats
path: root/src/H5I.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-07-28 12:27:56 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-07-28 12:27:56 (GMT)
commit0b7306beed3616d5e259ce3efa1dd0105f436fdb (patch)
tree4d5d467a608e5fc9ada867f913136de744750860 /src/H5I.c
parentad2f3285b3a0e55aab2014c9e395009df758fef6 (diff)
downloadhdf5-0b7306beed3616d5e259ce3efa1dd0105f436fdb.zip
hdf5-0b7306beed3616d5e259ce3efa1dd0105f436fdb.tar.gz
hdf5-0b7306beed3616d5e259ce3efa1dd0105f436fdb.tar.bz2
[svn-r19133] Description:
Correct traversal of user-defined links (including external links) to retain path information of object, allowing H5Iget_name() queries to work quickly (without searching entire destination file). This required some refactoring and addition of a mechanism to detect if a "fast" query was performed (for the tests). Minor code cleanups, etc. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.4 (amazon) in debug mode Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
Diffstat (limited to 'src/H5I.c')
-rw-r--r--src/H5I.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/H5I.c b/src/H5I.c
index d6655e0..be3c9d6 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -896,7 +896,7 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref)
/* new ID to check for */
next_id = H5I_MAKE(type, type_ptr->nextid);
- hash_loc = H5I_LOC(type_ptr->nextid, type_ptr->hash_size);
+ hash_loc = (unsigned)H5I_LOC(type_ptr->nextid, type_ptr->hash_size);
curr_id = type_ptr->id_list[hash_loc];
if(curr_id == NULL)
break; /* Ha! this is not likely... */
@@ -1421,15 +1421,16 @@ H5I_dec_ref(hid_t id, hbool_t app_ref)
if(!type_ptr->free_func || (type_ptr->free_func)((void *)id_ptr->obj_ptr) >= 0) {
H5I_remove(id);
ret_value = 0;
- } else {
+ } /* end if */
+ else
ret_value = FAIL;
- }
- } else {
+ } /* end if */
+ else {
--(id_ptr->count);
- if (app_ref)
+ if(app_ref)
--(id_ptr->app_count);
HDassert(id_ptr->count >= id_ptr->app_count);
- ret_value = app_ref ? id_ptr->app_count : id_ptr->count;
+ ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count);
}
done:
@@ -1525,7 +1526,7 @@ H5I_inc_ref(hid_t id, hbool_t app_ref)
++(id_ptr->app_count);
/* Set return value */
- ret_value = app_ref ? id_ptr->app_count : id_ptr->count;
+ ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1615,7 +1616,7 @@ H5I_get_ref(hid_t id, hbool_t app_ref)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID")
/* Set return value */
- ret_value = app_ref ? id_ptr->app_count : id_ptr->count;
+ ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1696,7 +1697,7 @@ H5I_inc_type_ref(H5I_type_t type)
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type")
/* Set return value */
- ret_value = ++(type_ptr->count);
+ ret_value = (int)(++(type_ptr->count));
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1797,7 +1798,7 @@ H5I_dec_type_ref(H5I_type_t type)
} /* end if */
else {
--(type_ptr->count);
- ret_value = type_ptr->count;
+ ret_value = (herr_t)type_ptr->count;
} /* end else */
done:
@@ -1879,7 +1880,7 @@ H5I_get_type_ref(H5I_type_t type)
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type")
/* Set return value */
- ret_value = type_ptr->count;
+ ret_value = (int)type_ptr->count;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2133,13 +2134,18 @@ done:
ssize_t
H5Iget_name(hid_t id, char *name/*out*/, size_t size)
{
+ H5G_loc_t loc; /* Object location */
ssize_t ret_value; /* Return value */
FUNC_ENTER_API(H5Iget_name, FAIL)
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")
+
/* Call internal group routine to retrieve object's name */
- if((ret_value = H5G_get_name(id, name, size, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0)
+ if((ret_value = H5G_get_name(&loc, name, size, NULL, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name")
done:
@@ -2187,7 +2193,6 @@ done:
* ID given an object ID.
*
* Return: Success: file ID
- *
* Failure: a negative value
*
* Programmer: Raymond Lu
@@ -2198,7 +2203,6 @@ done:
hid_t
H5I_get_file_id(hid_t obj_id, hbool_t app_ref)
{
- H5G_loc_t loc; /* Location of object */
H5I_type_t type; /* ID type */
hid_t ret_value; /* Return value */
@@ -2207,18 +2211,24 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref)
/* Get object type */
type = H5I_TYPE(obj_id);
if(type == H5I_FILE) {
- ret_value = obj_id;
-
- /* Increment reference count on atom. */
- if(H5I_inc_ref(ret_value, app_ref) < 0)
+ /* 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")
- }
+
+ /* Set return value */
+ ret_value = obj_id;
+ } /* end if */
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")
+
+ /* 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 */
else
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID")