summaryrefslogtreecommitdiffstats
path: root/src/H5Spoint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@koziol.gov>2019-06-16 02:25:28 (GMT)
committerQuincey Koziol <koziol@koziol.gov>2019-06-16 02:25:28 (GMT)
commit0525ee122f1394439f42055cf2fb5ca33ed985bb (patch)
tree3a6731bdfd04e386513818d28ba82fd40f02f4a9 /src/H5Spoint.c
parent462b924eca41b01c312d9533869f6bcaf4cc2d55 (diff)
downloadhdf5-0525ee122f1394439f42055cf2fb5ca33ed985bb.zip
hdf5-0525ee122f1394439f42055cf2fb5ca33ed985bb.tar.gz
hdf5-0525ee122f1394439f42055cf2fb5ca33ed985bb.tar.bz2
New hyperslab selection routines and new public selection iterator routines.
Diffstat (limited to 'src/H5Spoint.c')
-rw-r--r--src/H5Spoint.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 445566a..7fa232d 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -180,14 +180,25 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t);
static herr_t
H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter)
{
- FUNC_ENTER_STATIC_NOERR
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(space && H5S_SEL_POINTS == H5S_GET_SELECT_TYPE(space));
HDassert(iter);
- /* Share point list for internal iterations */
- iter->u.pnt.pnt_lst = space->select.sel_info.pnt_lst;
+ /* If this iterator is created from an API call, we must clone the
+ * selection now, as the dataspace could be modified or go out of scope.
+ */
+ if(iter->flags & H5S_SEL_ITER_API_CALL) {
+ /* Copy the point list */
+ if(NULL == (iter->u.pnt.pnt_lst = H5S__copy_pnt_list(space->select.sel_info.pnt_lst, space->extent.rank)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy point list")
+ } /* end if */
+ else
+ /* OK to share point list for internal iterations */
+ iter->u.pnt.pnt_lst = space->select.sel_info.pnt_lst;
/* Start at the head of the list of points */
iter->u.pnt.curr = iter->u.pnt.pnt_lst->head;
@@ -195,7 +206,8 @@ H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter)
/* Initialize type of selection iterator */
iter->type = H5S_sel_iter_point;
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__point_iter_init() */
@@ -537,13 +549,17 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__point_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter)
+H5S__point_iter_release(H5S_sel_iter_t * iter)
{
FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(iter);
+ /* If this iterator is created from an API call, we must free the point list */
+ if(iter->flags & H5S_SEL_ITER_API_CALL)
+ H5S__free_pnt_list(iter->u.pnt.pnt_lst);
+
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5S__point_iter_release() */