summaryrefslogtreecommitdiffstats
path: root/src/H5Sselect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Sselect.c')
-rw-r--r--src/H5Sselect.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 6c8b898..13233ce 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -431,7 +431,7 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-H5_ATTR_PURE hssize_t
+H5_ATTR_PURE hsize_t
H5S_get_select_npoints(const H5S_t *space)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -439,7 +439,7 @@ H5S_get_select_npoints(const H5S_t *space)
/* Check args */
HDassert(space);
- FUNC_LEAVE_NOAPI((hssize_t)space->select.num_elem)
+ FUNC_LEAVE_NOAPI(space->select.num_elem)
} /* end H5S_get_select_npoints() */
@@ -2601,9 +2601,9 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
{
H5S_t *new_space = NULL; /* New dataspace constructed */
H5S_t *tmp_src_intersect_space = NULL; /* Temporary SIS converted from points->hyperslabs */
- H5S_sel_iter_t ss_iter; /* Selection iterator for src_space */
+ H5S_sel_iter_t *ss_iter = NULL; /* Selection iterator for src_space */
hbool_t ss_iter_init = FALSE; /* Whether ss_iter has been initialized */
- H5S_sel_iter_t ds_iter; /* Selection iterator for dst_space */
+ H5S_sel_iter_t *ds_iter = NULL; /* Selection iterator for dst_space */
hbool_t ds_iter_init = FALSE; /* Whether ds_iter has been initialized */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2617,6 +2617,11 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
HDassert(H5S_GET_SELECT_NPOINTS(src_space) == H5S_GET_SELECT_NPOINTS(dst_space));
HDassert(H5S_GET_EXTENT_NDIMS(src_space) == H5S_GET_EXTENT_NDIMS(src_intersect_space));
+ if(NULL == (ss_iter = H5FL_CALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
+ if(NULL == (ds_iter = H5FL_CALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
+
/* Create new space, using dst extent. Start with "all" selection. */
if(NULL == (new_space = H5S_create(H5S_SIMPLE)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create output dataspace")
@@ -2717,20 +2722,20 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
/* Initialize iterators */
- if(H5S_select_iter_init(&ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0)
+ if(H5S_select_iter_init(ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize source space selection iterator")
ss_iter_init = TRUE;
- if(H5S_select_iter_init(&ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0)
+ if(H5S_select_iter_init(ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize destination space selection iterator")
ds_iter_init = TRUE;
/* Iterate over points */
do {
- HDassert(ss_iter.elmt_left > 0);
- HDassert(ss_iter.elmt_left > 0);
+ HDassert(ss_iter->elmt_left > 0);
+ HDassert(ss_iter->elmt_left > 0);
/* Get SS coords */
- if(H5S_SELECT_ITER_COORDS(&ss_iter, coords) < 0)
+ if(H5S_SELECT_ITER_COORDS(ss_iter, coords) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get source selection coordinates")
/* Check for intersection */
@@ -2740,7 +2745,7 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
/* Add point if it intersects */
if(intersect) {
/* Get DS coords */
- if(H5S_SELECT_ITER_COORDS(&ds_iter, coords) < 0)
+ if(H5S_SELECT_ITER_COORDS(ds_iter, coords) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get destination selection coordinates")
/* Add point to new_space */
@@ -2749,14 +2754,14 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
} /* end if */
/* Advance iterators */
- if(H5S_SELECT_ITER_NEXT(&ss_iter, 1) < 0)
+ if(H5S_SELECT_ITER_NEXT(ss_iter, 1) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne source selection iterator")
- ss_iter.elmt_left--;
- if(H5S_SELECT_ITER_NEXT(&ds_iter, 1) < 0)
+ ss_iter->elmt_left--;
+ if(H5S_SELECT_ITER_NEXT(ds_iter, 1) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne destination selection iterator")
- ds_iter.elmt_left--;
- } while(ss_iter.elmt_left > 0);
- HDassert(H5S_SELECT_ITER_NELMTS(&ds_iter) == 0);
+ ds_iter->elmt_left--;
+ } while(ss_iter->elmt_left > 0);
+ HDassert(H5S_SELECT_ITER_NELMTS(ds_iter) == 0);
} /* end if */
else {
HDassert(H5S_GET_SELECT_TYPE(src_space) != H5S_SEL_NONE);
@@ -2783,11 +2788,14 @@ done:
/* General cleanup */
if(tmp_src_intersect_space && H5S_close(tmp_src_intersect_space) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release temporary dataspace")
- if(ss_iter_init && H5S_SELECT_ITER_RELEASE(&ss_iter) < 0)
+ if(ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release source selection iterator")
- if(ds_iter_init && H5S_SELECT_ITER_RELEASE(&ds_iter) < 0)
+ if(ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release destination selection iterator")
+ ss_iter = H5FL_FREE(H5S_sel_iter_t, ss_iter);
+ ds_iter = H5FL_FREE(H5S_sel_iter_t, ds_iter);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_select_project_intersection() */