summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2000-04-05 20:51:27 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2000-04-05 20:51:27 (GMT)
commitd1de790d2530b44d5671452f7db52fdee8e839f5 (patch)
treeb87e5cc6c501fa87e8466c93fa83828676cd82dc /src
parent88c72b4568f0eef918ab9ca17e1e7c5c0dc2435a (diff)
downloadhdf5-d1de790d2530b44d5671452f7db52fdee8e839f5.zip
hdf5-d1de790d2530b44d5671452f7db52fdee8e839f5.tar.gz
hdf5-d1de790d2530b44d5671452f7db52fdee8e839f5.tar.bz2
[svn-r2081] Fixed a problem in H5Giterate which was not updating the 'index' paramater for
certain return values from the callback.
Diffstat (limited to 'src')
-rw-r--r--src/H5G.c12
-rw-r--r--src/H5Gnode.c52
-rw-r--r--src/H5Gpkg.h1
3 files changed, 39 insertions, 26 deletions
diff --git a/src/H5G.c b/src/H5G.c
index edac93a..8ef6db5 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -316,12 +316,18 @@ H5Giterate(hid_t loc_id, const char *name, int *idx,
udata.op = op;
udata.op_data = op_data;
+ /* Set the number of entries looked at to zero */
+ udata.final_ent = 0;
+
/* Iterate over the group members */
if ((ret_value = H5B_iterate (H5G_fileof(udata.group), H5B_SNODE,
- udata.group->ent.cache.stab.btree_addr,
- &udata))<0) {
- HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed");
+ udata.group->ent.cache.stab.btree_addr, &udata))<0) {
+ HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed");
}
+
+ /* Set the index we stopped at */
+ *idx=udata.final_ent;
+
H5I_dec_ref (udata.group_id); /*also closes udata.group*/
FUNC_LEAVE (ret_value);
}
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index b0071d5..b99653f 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -1091,39 +1091,45 @@ H5G_node_iterate (H5F_t *f, void UNUSED *_lt_key, haddr_t addr,
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
- for (i=0; i<nsyms; i++) name_off[i] = sn->entry[i].name_off;
+ for (i=0; i<nsyms; i++)
+ name_off[i] = sn->entry[i].name_off;
sn = NULL;
/*
* Iterate over the symbol table node entries.
*/
for (i=0, ret_value=0; i<nsyms && 0==ret_value; i++) {
- if (bt_udata->skip>0) {
- --bt_udata->skip;
- } else {
- name = H5HL_peek (f, bt_udata->group->ent.cache.stab.heap_addr,
- name_off[i]);
- assert (name);
- n = HDstrlen (name);
- if (n+1>sizeof(buf)) {
- if (NULL==(s = H5MM_malloc (n+1))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- } else {
- s = buf;
- }
- HDstrcpy (s, name);
- ret_value = (bt_udata->op)(bt_udata->group_id, s,
- bt_udata->op_data);
- if (s!=buf) H5MM_xfree (s);
- }
+ if (bt_udata->skip>0) {
+ --bt_udata->skip;
+ } else {
+ name = H5HL_peek (f, bt_udata->group->ent.cache.stab.heap_addr,
+ name_off[i]);
+ assert (name);
+ n = HDstrlen (name);
+ if (n+1>sizeof(buf)) {
+ if (NULL==(s = H5MM_malloc (n+1))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ } else {
+ s = buf;
+ }
+ HDstrcpy (s, name);
+ ret_value = (bt_udata->op)(bt_udata->group_id, s,
+ bt_udata->op_data);
+ if (s!=buf)
+ H5MM_xfree (s);
+ }
+
+ /* Increment the number of entries passed through */
+ /* (whether we skipped them or not) */
+ bt_udata->final_ent++;
}
if (ret_value<0) {
- HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed");
+ HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed");
}
- done:
+done:
name_off = H5MM_xfree (name_off);
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index e2b657c..17ec6d8 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -104,6 +104,7 @@ typedef struct H5G_bt_ud2_t {
void *op_data; /*user-defined operator data */
/* upward */
+ int final_ent; /*final entry looked at */
} H5G_bt_ud2_t;