summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;