summaryrefslogtreecommitdiffstats
path: root/hl/src/H5DS.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2009-04-08 20:55:02 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2009-04-08 20:55:02 (GMT)
commitc62ae38c01b497b8c1139a0be71ea0bbc561fccd (patch)
tree5ac9413eeda58f6c24732a2bf91c3d20680e0c2f /hl/src/H5DS.c
parent90bcab507221dfd7837d6f7cb66024550fff215b (diff)
downloadhdf5-c62ae38c01b497b8c1139a0be71ea0bbc561fccd.zip
hdf5-c62ae38c01b497b8c1139a0be71ea0bbc561fccd.tar.gz
hdf5-c62ae38c01b497b8c1139a0be71ea0bbc561fccd.tar.bz2
[svn-r16706] #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: windows, linux
Diffstat (limited to 'hl/src/H5DS.c')
-rw-r--r--hl/src/H5DS.c38
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;