summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-12-06 14:57:06 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-12-06 14:57:06 (GMT)
commit1b1e1ebbbd5b4d18c5f413e79b58f7f7e782519f (patch)
tree27b6581ccbe1c65b5b57cba9aef822f8f7cf58fe
parentaaff647518543633aa1b95649666bffb02b758a4 (diff)
downloadhdf5-1b1e1ebbbd5b4d18c5f413e79b58f7f7e782519f.zip
hdf5-1b1e1ebbbd5b4d18c5f413e79b58f7f7e782519f.tar.gz
hdf5-1b1e1ebbbd5b4d18c5f413e79b58f7f7e782519f.tar.bz2
[svn-r7915] Purpose:
Bug fix Description: Make a copy of the index value for H5Giterate and use that instead of dereferencing the index pointer. Platforms tested: FreeBSD 4.9 (sleipnir) too minor to need h5committest
-rw-r--r--release_docs/RELEASE.txt3
-rw-r--r--src/H5G.c19
2 files changed, 13 insertions, 9 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 10f7127..08e4edd 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -93,6 +93,9 @@ Bug Fixes since HDF5-1.6.0 release
Library
-------
+ - Fixed H5Giterate to avoid re-using index parameter after iteration
+ callback has been called (allows iteration callback to modify the
+ index parameter itself). QAK - 2003/12/06
- Fixed various floating-point conversion problems, including a
change which could corrupt data when converting from double->float.
QAK - 2003/11/24
diff --git a/src/H5G.c b/src/H5G.c
index d8b3fe7..d90278d 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -375,26 +375,27 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Giterate(hid_t loc_id, const char *name, int *idx,
+H5Giterate(hid_t loc_id, const char *name, int *idx_p,
H5G_iterate_t op, void *op_data)
{
- int _idx = 0;
+ int idx;
H5G_bt_ud2_t udata;
H5G_entry_t *loc = NULL;
H5G_t *grp = NULL;
herr_t ret_value;
FUNC_ENTER_API(H5Giterate, FAIL);
- H5TRACE5("e","is*Isxx",loc_id,name,idx,op,op_data);
+ H5TRACE5("e","is*Isxx",loc_id,name,idx_p,op,op_data);
/* Check args */
if (NULL==(loc=H5G_loc (loc_id)))
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
if (!name || !*name)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
- if (!idx)
- idx = &_idx;
- if (*idx<0)
+ idx = (idx_p == NULL ? 0 : *idx_p);
+ if (!idx_p)
+ idx_p = &idx;
+ if (idx<0)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified");
if (!op)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified");
@@ -411,7 +412,7 @@ H5Giterate(hid_t loc_id, const char *name, int *idx,
}
/* Build udata to pass through H5B_iterate() to H5G_node_iterate() */
- udata.skip = *idx;
+ udata.skip = idx;
udata.ent = &(grp->ent);
udata.op = op;
udata.op_data = op_data;
@@ -428,11 +429,11 @@ H5Giterate(hid_t loc_id, const char *name, int *idx,
/* Check for too high of a starting index (ex post facto :-) */
/* (Skipping exactly as many entries as are in the group is currently an error) */
- if (*idx>0 && *idx>=udata.final_ent)
+ if (idx>0 && idx>=udata.final_ent)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified");
/* Set the index we stopped at */
- *idx=udata.final_ent;
+ *idx_p=udata.final_ent;
done:
FUNC_LEAVE_API(ret_value);