diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-07-30 18:53:01 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-07-30 18:53:01 (GMT) |
commit | 0c9c34fab681a559633cbae215cb49ca812f4a3d (patch) | |
tree | ea192413d801b0a9d550172ca3e8f8d7771f3659 /src/H5G.c | |
parent | ddb2af421f244dd92e8d7f53a1bb2b9a9df14bde (diff) | |
download | hdf5-0c9c34fab681a559633cbae215cb49ca812f4a3d.zip hdf5-0c9c34fab681a559633cbae215cb49ca812f4a3d.tar.gz hdf5-0c9c34fab681a559633cbae215cb49ca812f4a3d.tar.bz2 |
[svn-r11176] Purpose:
Bug fix
Description:
Correct problems when querying information about a group that was opened
by dereferencing an object reference.
Solution:
Read in symbol table information instead of rely on it being cached.
Platforms tested:
FreeBSD 4.11 (sleipnir)
Too minor to require h5committest
Diffstat (limited to 'src/H5G.c')
-rw-r--r-- | src/H5G.c | 69 |
1 files changed, 25 insertions, 44 deletions
@@ -104,7 +104,6 @@ #include "H5HLprivate.h" /* Local Heaps */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ /* Local macros */ @@ -592,11 +591,8 @@ ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) { H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */ -#ifdef OLD_WAY - hsize_t num_objs; -#endif /* OLD_WAY */ ssize_t ret_value = FAIL; - + FUNC_ENTER_API(H5Gget_objname_by_idx, FAIL); H5TRACE4("Zs","ihsz",loc_id,idx,name,size); @@ -605,19 +601,7 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID"); if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); - -#ifdef OLD_WAY -/* Don't check for the number of objects in the group currently, because this - * has to iterate through the group in order to find out the information. - * We might as well just iterate through all the group entries and error out - * if we didn't find the index we are looking for. -QAK - */ - if (H5G_get_num_objs(loc, &num_objs, H5AC_ind_dxpl_id)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to retrieve number of members"); - if(idx >= num_objs) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "index out of bound"); -#endif /* OLD_WAY */ - + /*call private function*/ ret_value = H5G_get_objname_by_idx(loc, idx, name, size, H5AC_ind_dxpl_id); @@ -647,9 +631,6 @@ H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) { H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */ -#ifdef OLD_WAY - hsize_t num_objs; -#endif /* OLD_WAY */ H5G_obj_t ret_value; FUNC_ENTER_API(H5Gget_objtype_by_idx, H5G_UNKNOWN); @@ -660,19 +641,7 @@ H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID"); if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a group"); - -#ifdef OLD_WAY -/* Don't check for the number of objects in the group currently, because this - * has to iterate through the group in order to find out the information. - * We might as well just iterate through all the group entries and error out - * if we didn't find the index we are looking for. -QAK - */ - if (H5G_get_num_objs(loc, &num_objs, H5AC_ind_dxpl_id)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "unable to retrieve number of members"); - if(idx >= num_objs) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "index out of bound"); -#endif /* OLD_WAY */ - + /*call private function*/ ret_value = H5G_get_objtype_by_idx(loc, idx, H5AC_ind_dxpl_id); @@ -2912,21 +2881,25 @@ done: static herr_t H5G_get_num_objs(H5G_entry_t *loc, hsize_t *num_objs, hid_t dxpl_id) { + H5O_stab_t stab_mesg; /*info about B-tree */ herr_t ret_value; FUNC_ENTER_NOAPI(H5G_get_num_objs, FAIL); /* Sanity check */ assert(loc); - assert(loc->type==H5G_CACHED_STAB); assert(num_objs); /* Reset the number of objects in the group */ *num_objs = 0; + /* Get the B-tree info */ + if (NULL==H5O_read (loc, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) + HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address"); + /* Iterate over the group members */ if ((ret_value = H5B_iterate (loc->file, dxpl_id, H5B_SNODE, - H5G_node_sumup, loc->cache.stab.btree_addr, num_objs))<0) + H5G_node_sumup, stab_mesg.btree_addr, num_objs))<0) HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed"); done: @@ -2954,6 +2927,7 @@ done: static ssize_t H5G_get_objname_by_idx(H5G_entry_t *loc, hsize_t idx, char* name, size_t size, hid_t dxpl_id) { + H5O_stab_t stab_mesg; /*info about local heap & B-tree */ H5G_bt_ud3_t udata; /* Iteration information */ ssize_t ret_value; /* Return value */ @@ -2961,17 +2935,20 @@ H5G_get_objname_by_idx(H5G_entry_t *loc, hsize_t idx, char* name, size_t size, h /* Sanity check */ assert(loc); - assert(loc->type==H5G_CACHED_STAB); + + /* Get the B-tree & local heap info */ + if (NULL==H5O_read (loc, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) + HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address"); /* Set iteration information */ udata.idx = idx; udata.num_objs = 0; - udata.ent = loc; + udata.mesg = &stab_mesg; udata.name = NULL; /* Iterate over the group members */ if ((ret_value = H5B_iterate (loc->file, dxpl_id, H5B_SNODE, - H5G_node_name, loc->cache.stab.btree_addr, &udata))<0) + H5G_node_name, stab_mesg.btree_addr, &udata))<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "iteration operator failed"); /* If we don't know the name now, we almost certainly went out of bounds */ @@ -3016,24 +2993,28 @@ done: static H5G_obj_t H5G_get_objtype_by_idx(H5G_entry_t *loc, hsize_t idx, hid_t dxpl_id) { - H5G_bt_ud3_t udata; /* User data for B-tree callback */ - H5G_obj_t ret_value; /* Return value */ + H5O_stab_t stab_mesg; /*info about local heap & B-tree */ + H5G_bt_ud3_t udata; /* User data for B-tree callback */ + H5G_obj_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5G_get_objtype_by_idx, H5G_UNKNOWN); /* Sanity check */ assert(loc); - assert(loc->type==H5G_CACHED_STAB); + + /* Get the B-tree & local heap info */ + if (NULL==H5O_read (loc, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) + HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address"); /* Set iteration information */ udata.idx = idx; udata.num_objs = 0; - udata.ent = loc; + udata.mesg = &stab_mesg; udata.type = H5G_UNKNOWN; /* Iterate over the group members */ if (H5B_iterate (loc->file, dxpl_id, H5B_SNODE, - H5G_node_type, loc->cache.stab.btree_addr, &udata)<0) + H5G_node_type, stab_mesg.btree_addr, &udata)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "iteration operator failed"); /* If we don't know the type now, we almost certainly went out of bounds */ |