diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-07-21 14:49:11 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-07-21 14:49:11 (GMT) |
commit | 1e2ddfc8b1847c4b1f67c764d4920c5d1e0c538d (patch) | |
tree | 60e8d8ee4b4fa77ef7a01ebf106d53b9d7675a32 /src/H5I.c | |
parent | c9b45e24d5f1935d5356cf90f0521d1e82efc4e3 (diff) | |
download | hdf5-1e2ddfc8b1847c4b1f67c764d4920c5d1e0c538d.zip hdf5-1e2ddfc8b1847c4b1f67c764d4920c5d1e0c538d.tar.gz hdf5-1e2ddfc8b1847c4b1f67c764d4920c5d1e0c538d.tar.bz2 |
[svn-r11094] Purpose:
Bug fix
Description:
Rewrite code for mounting files to clean up layers of kludges and implement
a much cleaner and more maintainable design.
Platforms tested:
FreeBSD 4.11 (sleipnir)
Linux 2.4
Diffstat (limited to 'src/H5I.c')
-rw-r--r-- | src/H5I.c | 37 |
1 files changed, 16 insertions, 21 deletions
@@ -114,7 +114,6 @@ H5FL_DEFINE_STATIC(H5I_id_info_t); /*--------------------- Local function prototypes ---------------------------*/ static H5I_id_info_t *H5I_find_id(hid_t id); static hid_t H5I_get_file_id(hid_t obj_id); -static int H5I_get_ref(hid_t id); #ifdef H5I_DEBUG_OUTPUT static herr_t H5I_debug(H5I_type_t grp); #endif /* H5I_DEBUG_OUTPUT */ @@ -311,9 +310,6 @@ int H5I_nmembers(H5I_type_t grp) { H5I_id_group_t *grp_ptr = NULL; - H5I_id_info_t *cur=NULL; - int n=0; - unsigned i; int ret_value; FUNC_ENTER_NOAPI(H5I_nmembers, FAIL); @@ -323,12 +319,8 @@ H5I_nmembers(H5I_type_t grp) if (NULL==(grp_ptr=H5I_id_group_list_g[grp]) || grp_ptr->count<=0) HGOTO_DONE(0); - for (i=0; i<grp_ptr->hash_size; i++) - for (cur=grp_ptr->id_list[i]; cur; cur=cur->next) - n++; - /* Set return value */ - ret_value=n; + H5_ASSIGN_OVERFLOW(ret_value, grp_ptr->ids, unsigned, int); done: FUNC_LEAVE_NOAPI(ret_value); @@ -1127,7 +1119,7 @@ done: * *------------------------------------------------------------------------- */ -static int +int H5I_get_ref(hid_t id) { H5I_type_t grp; /*group the object is in*/ @@ -1203,20 +1195,23 @@ H5I_search(H5I_type_t grp, H5I_search_func_t func, void *key) if (grp_ptr == NULL || grp_ptr->count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid group"); - /* Start at the beginning of the array */ - for (i=0; i<grp_ptr->hash_size; i++) { - id_ptr = grp_ptr->id_list[i]; - while (id_ptr) { - next_id= id_ptr->next; /* Protect against ID being deleted in callback */ - if ((*func)(id_ptr->obj_ptr, id_ptr->id, key)) - HGOTO_DONE(id_ptr->obj_ptr); /*found the item*/ - id_ptr = next_id; - } - } + /* Only iterate through hash table if there are IDs in group */ + if(grp_ptr->ids > 0) { + /* Start at the beginning of the array */ + for (i=0; i<grp_ptr->hash_size; i++) { + id_ptr = grp_ptr->id_list[i]; + while (id_ptr) { + next_id= id_ptr->next; /* Protect against ID being deleted in callback */ + if ((*func)(id_ptr->obj_ptr, id_ptr->id, key)) + HGOTO_DONE(id_ptr->obj_ptr); /*found the item*/ + id_ptr = next_id; + } /* end while */ + } /* end for */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); -} +} /* end H5I_search() */ /*------------------------------------------------------------------------- |