summaryrefslogtreecommitdiffstats
path: root/src/H5B.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-06-23 13:24:56 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-06-23 13:24:56 (GMT)
commit403f1bac7cd811261a72faa8392edcecbe0e7563 (patch)
tree1f7bad287b30b06f27a8ca8fb4b343c1dfd1d9be /src/H5B.c
parentff818d2d474b54787de2ef55b7fc9ba1bbcb1f29 (diff)
downloadhdf5-403f1bac7cd811261a72faa8392edcecbe0e7563.zip
hdf5-403f1bac7cd811261a72faa8392edcecbe0e7563.tar.gz
hdf5-403f1bac7cd811261a72faa8392edcecbe0e7563.tar.bz2
[svn-r7080] Purpose:
Bug fix (backward compatibility) Description: Changes we've made during development of the 1.5.x branch had broken the feature of allowing user's callbacks to H5Giterate to return a value through the library back to the application which called H5Giterate. Solution: Correctly pass along iterator callback return value and adjust internal library code to conform to this design. Platforms tested: FreeBSD 4.8 (sleipnir) h5committest
Diffstat (limited to 'src/H5B.c')
-rw-r--r--src/H5B.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/H5B.c b/src/H5B.c
index 5f244f3..3c50882 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -1517,8 +1517,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
haddr_t *child = NULL;
uint8_t *key = NULL;
int i, nchildren;
- herr_t ret_value = SUCCEED;
- H5B_iterate_t ret_flag = H5B_ITER_CONT;
+ herr_t ret_value;
FUNC_ENTER_NOAPI(H5B_iterate, FAIL);
@@ -1535,7 +1534,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node");
if (bt->level > 0) {
/* Keep following the left-most child until we reach a leaf node. */
- if (H5B_iterate(f, dxpl_id, type, op, bt->child[0], udata)<0)
+ if ((ret_value=H5B_iterate(f, dxpl_id, type, op, bt->child[0], udata))<0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node");
} else {
/*
@@ -1545,7 +1544,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
if (NULL==(child=H5FL_ARR_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) ||
NULL==(key=H5MM_malloc((2*H5F_KVALUE(f, type)+1)*type->sizeof_nkey)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- for (cur_addr=addr, ret_value=0; H5F_addr_defined(cur_addr); cur_addr=next_addr) {
+ for (cur_addr=addr, ret_value=0; H5F_addr_defined(cur_addr) && !ret_value; cur_addr=next_addr) {
/*
* Save all the child addresses and native keys since we can't
@@ -1570,16 +1569,11 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
* Perform the iteration operator, which might invoke an
* application callback.
*/
- for (i=0; i<nchildren && ret_flag==H5B_ITER_CONT; i++) {
- ret_flag = (*op)(f, dxpl_id, key+i*type->sizeof_nkey,
+ for (i=0, ret_value=H5B_ITER_CONT; i<nchildren && !ret_value; i++) {
+ ret_value = (*op)(f, dxpl_id, key+i*type->sizeof_nkey,
child[i], key+(i+1)*type->sizeof_nkey, udata);
- if (ret_flag==H5B_ITER_ERROR) {
+ if (ret_value<0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed");
- } else if(ret_flag==H5B_ITER_STOP) {
- HGOTO_DONE(SUCCEED);
- } else {
- ;
- }
} /* end for */
} /* end for */
} /* end else */