diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2009-04-08 20:59:40 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2009-04-08 20:59:40 (GMT) |
commit | c2c03a86b3b7eda8b148111da1be9fbf43e73906 (patch) | |
tree | e727f79c82499f6f65f29e976e0853e04ae5b56f /hl/src | |
parent | 67870391007b38f3ebc39bcb6d5b1e08cf65e95c (diff) | |
download | hdf5-c2c03a86b3b7eda8b148111da1be9fbf43e73906.zip hdf5-c2c03a86b3b7eda8b148111da1be9fbf43e73906.tar.gz hdf5-c2c03a86b3b7eda8b148111da1be9fbf43e73906.tar.bz2 |
[svn-r16707] merge 16706 from trunk
#1538 (B2) Problems with Dim Scale APIs reported by Mathworks
ISSUE2: the scale index input/output parameter value passed to H5DSiterate_scales was not always incremented (it returns the scale index current iteration).
SOLUTION FOR ISSUE2: modified the cycle in H5DSiterate_scales so that the scale index is always incremented
TEST: added some test cases with calls to invalid indices and H5DSiterate_scales with return scale indices and visitor data
tested: linux
Diffstat (limited to 'hl/src')
-rw-r--r-- | hl/src/H5DS.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 1d1e245..c3b444c 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -1292,11 +1292,12 @@ out: * Parameters: * * hid_t DID; IN: the dataset -* unsigned int dim; IN: the dimension of the dataset -* int *idx; IN/OUT: input the index to start iterating, output the -* next index to visit. If NULL, start at the first position. -* H5DS_iterate_t visitor; IN: the visitor function -* void *visitor_data; IN: arbitrary data to pass to the visitor function. +* unsigned int DIM; IN: the dimension of the dataset +* int *DS_IDX; IN/OUT: on input the dimension scale index to start iterating, +* on output the next index to visit. If NULL, start at +* the first position. +* H5DS_iterate_t VISITOR; IN: the visitor function +* void *VISITOR_DATA; IN: arbitrary data to pass to the visitor function. * * Iterate over all scales of DIM, calling an application callback * with the item, key and any operator data. @@ -1324,7 +1325,7 @@ out: herr_t H5DSiterate_scales(hid_t did, unsigned int dim, - int *idx, + int *ds_idx, H5DS_iterate_t visitor, void *visitor_data ) { @@ -1358,9 +1359,9 @@ herr_t H5DSiterate_scales(hid_t did, return FAIL; /* parameter range checking */ - if (idx!=NULL) + if (ds_idx!=NULL) { - if (*idx>=nscales) + if (*ds_idx>=nscales) return FAIL; } @@ -1376,6 +1377,9 @@ herr_t H5DSiterate_scales(hid_t did, if(H5Sclose(sid) < 0) goto out; + if ( dim >= (unsigned)rank ) + return FAIL; + /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; @@ -1404,8 +1408,8 @@ herr_t H5DSiterate_scales(hid_t did, if ( buf[dim].len > 0 ) { - if (idx!=NULL) - j_idx = *idx; + if (ds_idx!=NULL) + j_idx = *ds_idx; else j_idx=0; @@ -1422,14 +1426,16 @@ herr_t H5DSiterate_scales(hid_t did, goto out; } H5E_END_TRY; - if((ret_value=(visitor)(did,dim,scale_id,visitor_data))!=0) + /* set the return IDX OUT value at current scale index */ + if (ds_idx!=NULL) { - /* set the return IDX OUT value at current scale index and break */ - if (idx!=NULL) - { - *idx = i; - } + *ds_idx = i; + } + if((ret_value=(visitor)(did,dim,scale_id,visitor_data))!=0) + { + /* break */ + /* close the DS id */ if (H5Dclose(scale_id) < 0) goto out; |