summaryrefslogtreecommitdiffstats
path: root/src/H5Sselect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Sselect.c')
-rw-r--r--src/H5Sselect.c910
1 files changed, 566 insertions, 344 deletions
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 6e6ca76..fdd897c 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -17,26 +17,59 @@
* Purpose: Dataspace selection functions.
*/
+/****************/
+/* Module Setup */
+/****************/
+
#include "H5Smodule.h" /* This source code file is part of the H5S module */
+/***********/
+/* Headers */
+/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
#include "H5Spkg.h" /* Dataspaces */
-#include "H5VMprivate.h" /* Vector and array functions */
-#include "H5WBprivate.h" /* Wrapped Buffers */
+#include "H5VMprivate.h" /* Vector and array functions */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+/* All the valid public flags to H5Ssel_iter_create() */
+#define H5S_SEL_ITER_ALL_PUBLIC_FLAGS (H5S_SEL_ITER_GET_SEQ_LIST_SORTED | \
+ H5S_SEL_ITER_SHARE_WITH_DATASPACE)
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
-/* Local functions */
#ifdef LATER
static herr_t H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end);
static htri_t H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter);
static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter);
#endif /* LATER */
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
/* Declare a free list to manage the H5S_sel_iter_t struct */
H5FL_DEFINE(H5S_sel_iter_t);
@@ -47,6 +80,11 @@ H5FL_SEQ_EXTERN(size_t);
H5FL_SEQ_EXTERN(hsize_t);
+/*******************/
+/* Local Variables */
+/*******************/
+
+
/*--------------------------------------------------------------------------
NAME
@@ -78,13 +116,56 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset)
HDassert(offset);
/* Copy the offset over */
- HDmemcpy(space->select.offset, offset, sizeof(hssize_t)*space->extent.rank);
+ H5MM_memcpy(space->select.offset, offset, sizeof(hssize_t) * space->extent.rank);
/* Indicate that the offset was changed */
space->select.offset_changed = TRUE;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_select_offset() */
+} /* end H5S_select_offset() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Soffset_simple
+ PURPOSE
+ Changes the offset of a selection within a simple dataspace extent
+ USAGE
+ herr_t H5Soffset_simple(space_id, offset)
+ hid_t space_id; IN: Dataspace object to reset
+ const hssize_t *offset; IN: Offset to position the selection at
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ This function creates an offset for the selection within an extent, allowing
+ the same shaped selection to be moved to different locations within a
+ dataspace without requiring it to be re-defined.
+--------------------------------------------------------------------------*/
+herr_t
+H5Soffset_simple(hid_t space_id, const hssize_t *offset)
+{
+ H5S_t *space; /* Dataspace to query */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*Hs", space_id, offset);
+
+ /* Check args */
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace")
+ if(space->extent.rank == 0 || (H5S_GET_EXTENT_TYPE(space) == H5S_SCALAR
+ || H5S_GET_EXTENT_TYPE(space) == H5S_NULL))
+ HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace")
+ if(offset == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified")
+
+ /* Set the selection offset */
+ if(H5S_select_offset(space, offset) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Soffset_simple() */
/*--------------------------------------------------------------------------
@@ -139,9 +220,10 @@ done:
PURPOSE
Copy a selection from one dataspace to another
USAGE
- herr_t H5S_select_copy(dst, src)
+ herr_t H5S_select_copy(dst, src, share_selection)
H5S_t *dst; OUT: Pointer to the destination dataspace
H5S_t *src; IN: Pointer to the source dataspace
+ hbool_t; IN: Whether to share the selection between the dataspaces
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -177,7 +259,7 @@ H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_copy() */
+} /* end H5S_select_copy() */
/*-------------------------------------------------------------------------
@@ -211,44 +293,7 @@ H5S_select_release(H5S_t *ds)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_release() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5S_select_get_seq_list
- *
- * Purpose: Retrieves the next sequence of offset/length pairs for an
- * iterator on a dataspace
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * Tuesday, May 18, 2004
- *
- * Note: This routine participates in the "Inlining C function pointers"
- * pattern, don't call it directly, use the appropriate macro
- * defined in H5Sprivate.h.
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5S_select_get_seq_list(const H5S_t *space, unsigned flags,
- H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
- size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len)
-{
- herr_t ret_value = FAIL; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- HDassert(space);
-
- /* Call the selection type's get_seq_list function */
- if((ret_value = (*space->select.type->get_seq_list)(space, flags, iter, maxseq, maxbytes, nseq, nbytes, off, len)) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_get_seq_list() */
+} /* end H5S_select_release() */
/*-------------------------------------------------------------------------
@@ -278,10 +323,10 @@ H5S_select_serial_size(const H5S_t *space)
HDassert(space);
/* Call the selection type's serial_size function */
- ret_value=(*space->select.type->serial_size)(space);
+ ret_value = (*space->select.type->serial_size)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_serial_size() */
+} /* end H5S_select_serial_size() */
/*--------------------------------------------------------------------------
@@ -311,7 +356,7 @@ H5S_select_serial_size(const H5S_t *space)
herr_t
H5S_select_serialize(const H5S_t *space, uint8_t **p)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -319,10 +364,10 @@ H5S_select_serialize(const H5S_t *space, uint8_t **p)
HDassert(p);
/* Call the selection type's serialize function */
- ret_value=(*space->select.type->serialize)(space,p);
+ ret_value = (*space->select.type->serialize)(space, p);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_serialize() */
+} /* end H5S_select_serialize() */
/*--------------------------------------------------------------------------
@@ -359,7 +404,7 @@ H5Sget_select_npoints(hid_t spaceid)
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sget_select_npoints() */
+} /* H5Sget_select_npoints() */
/*--------------------------------------------------------------------------
@@ -382,7 +427,7 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-hssize_t
+H5_ATTR_PURE hssize_t
H5S_get_select_npoints(const H5S_t *space)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -391,7 +436,7 @@ H5S_get_select_npoints(const H5S_t *space)
HDassert(space);
FUNC_LEAVE_NOAPI((hssize_t)space->select.num_elem)
-} /* H5S_get_select_npoints() */
+} /* end H5S_get_select_npoints() */
/*--------------------------------------------------------------------------
@@ -413,8 +458,6 @@ H5S_get_select_npoints(const H5S_t *space)
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
- Christian Chilan 01/17/2007
- Changed the error return value from 0 to FAIL.
--------------------------------------------------------------------------*/
htri_t
H5Sselect_valid(hid_t spaceid)
@@ -433,7 +476,7 @@ H5Sselect_valid(hid_t spaceid)
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sselect_valid() */
+} /* end H5Sselect_valid() */
/*--------------------------------------------------------------------------
@@ -471,7 +514,7 @@ H5S_select_valid(const H5S_t *space)
ret_value = (*space->select.type->is_valid)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_valid() */
+} /* end H5S_select_valid() */
/*--------------------------------------------------------------------------
@@ -503,103 +546,46 @@ H5S_select_valid(const H5S_t *space)
herr_t
H5S_select_deserialize(H5S_t **space, const uint8_t **p)
{
- H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, either
- *space or a newly allocated one */
uint32_t sel_type; /* Pointer to the selection type */
- uint32_t version; /* Version number */
- uint8_t flags = 0; /* Flags */
herr_t ret_value = FAIL; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
HDassert(space);
- /* Allocate space if not provided */
- if(!*space) {
- if(NULL == (tmp_space = H5S_create(H5S_SIMPLE)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace")
- } /* end if */
- else
- tmp_space = *space;
+ /* Selection-type specific coding is moved to the callbacks. */
/* Decode selection type */
UINT32DECODE(*p, sel_type);
- /* Decode version */
- UINT32DECODE(*p, version);
-
- if(version >= (uint32_t)2) {
- /* Decode flags */
- flags = *(*p)++;
-
- /* Check for unknown flags */
- if(flags & ~H5S_SELECT_FLAG_BITS)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown flag for selection")
-
- /* Skip over the remainder of the header */
- *p += 4;
- } /* end if */
- else
- /* Skip over the remainder of the header */
- *p += 8;
-
- /* Decode and check or patch rank for point and hyperslab selections */
- if((sel_type == H5S_SEL_POINTS) || (sel_type == H5S_SEL_HYPERSLABS)) {
- uint32_t rank; /* Rank of dataspace */
-
- /* Decode the rank of the point selection */
- UINT32DECODE(*p,rank);
-
- if(!*space) {
- hsize_t dims[H5S_MAX_RANK];
-
- /* Patch the rank of the allocated dataspace */
- (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0]));
- if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions")
- } /* end if */
- else
- /* Verify the rank of the provided dataspace */
- if(rank != tmp_space->extent.rank)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace")
- } /* end if */
-
/* Make routine for selection type */
switch(sel_type) {
case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value = (*H5S_sel_point->deserialize)(tmp_space, version, flags, p);
+ ret_value = (*H5S_sel_point->deserialize)(space, p);
break;
case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value = (*H5S_sel_hyper->deserialize)(tmp_space, version, flags, p);
+ ret_value = (*H5S_sel_hyper->deserialize)(space, p);
break;
case H5S_SEL_ALL: /* Entire extent selected */
- ret_value = (*H5S_sel_all->deserialize)(tmp_space, version, flags, p);
+ ret_value = (*H5S_sel_all->deserialize)(space, p);
break;
case H5S_SEL_NONE: /* Nothing selected */
- ret_value = (*H5S_sel_none->deserialize)(tmp_space, version, flags, p);
+ ret_value = (*H5S_sel_none->deserialize)(space, p);
break;
default:
break;
- }
+ } /* end switch */
+
if(ret_value < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "can't deserialize selection")
- /* Return space to the caller if allocated */
- if(!*space)
- *space = tmp_space;
-
done:
- /* Free temporary space if not passed to caller (only happens on error) */
- if(!*space && tmp_space)
- if(H5S_close(tmp_space) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace")
-
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_deserialize() */
+} /* end H5S_select_deserialize() */
/*--------------------------------------------------------------------------
@@ -651,7 +637,7 @@ H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[])
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Sget_select_bounds() */
+} /* end H5Sget_select_bounds() */
/*--------------------------------------------------------------------------
@@ -693,10 +679,10 @@ H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
HDassert(start);
HDassert(end);
- ret_value = (*space->select.type->bounds)(space,start,end);
+ ret_value = (*space->select.type->bounds)(space, start, end);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_get_select_bounds() */
+} /* end H5S_get_select_bounds() */
/*--------------------------------------------------------------------------
@@ -736,7 +722,7 @@ H5S_get_select_offset(const H5S_t *space, hsize_t *offset)
ret_value = (*space->select.type->offset)(space, offset);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_get_select_offset() */
+} /* end H5S_get_select_offset() */
/*--------------------------------------------------------------------------
@@ -774,7 +760,7 @@ H5S_get_select_unlim_dim(const H5S_t *space)
ret_value = (*space->select.type->unlim_dim)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_get_select_unlim_dim() */
+} /* end H5S_get_select_unlim_dim() */
/*--------------------------------------------------------------------------
@@ -819,7 +805,7 @@ H5S_get_select_num_elem_non_unlim(const H5S_t *space,
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_get_select_unlim_dim() */
+} /* end H5S_get_select_unlim_dim() */
/*--------------------------------------------------------------------------
@@ -856,7 +842,7 @@ H5S_select_is_contiguous(const H5S_t *space)
ret_value = (*space->select.type->is_contiguous)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_is_contiguous() */
+} /* end H5S_select_is_contiguous() */
/*--------------------------------------------------------------------------
@@ -893,7 +879,7 @@ H5S_select_is_single(const H5S_t *space)
ret_value = (*space->select.type->is_single)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_is_single() */
+} /* end H5S_select_is_single() */
/*--------------------------------------------------------------------------
@@ -930,7 +916,7 @@ H5S_select_is_regular(const H5S_t *space)
ret_value = (*space->select.type->is_regular)(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_is_regular() */
+} /* end H5S_select_is_regular() */
/*--------------------------------------------------------------------------
@@ -957,7 +943,9 @@ H5S_select_is_regular(const H5S_t *space)
herr_t
H5S_select_adjust_u(H5S_t *space, const hsize_t *offset)
{
- herr_t ret_value = FAIL; /* Return value */
+ hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -965,10 +953,19 @@ H5S_select_adjust_u(H5S_t *space, const hsize_t *offset)
HDassert(space);
HDassert(offset);
- ret_value = (*space->select.type->adjust_u)(space, offset);
+ /* Check for an all-zero offset vector */
+ for(u = 0; u < space->extent.rank; u++)
+ if(0 != offset[u]) {
+ non_zero_offset = TRUE;
+ break;
+ } /* end if */
+
+ /* Only perform operation if the offset is non-zero */
+ if(non_zero_offset)
+ ret_value = (*space->select.type->adjust_u)(space, offset);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_adjust_u() */
+} /* end H5S_select_adjust_u() */
/*--------------------------------------------------------------------------
@@ -1007,7 +1004,7 @@ H5S_select_project_scalar(const H5S_t *space, hsize_t *offset)
ret_value = (*space->select.type->project_scalar)(space, offset);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_project_scalar() */
+} /* end H5S_select_project_scalar() */
/*--------------------------------------------------------------------------
@@ -1048,7 +1045,7 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset)
ret_value = (*space->select.type->project_simple)(space, new_space, offset);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_project_simple() */
+} /* end H5S_select_project_simple() */
/*--------------------------------------------------------------------------
@@ -1057,11 +1054,12 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset)
PURPOSE
Initializes iteration information for a selection.
USAGE
- herr_t H5S_select_iter_init(sel_iter, space, elmt_size)
+ herr_t H5S_select_iter_init(sel_iter, space, elmt_size, flags)
H5S_sel_iter_t *sel_iter; OUT: Selection iterator to initialize.
H5S_t *space; IN: Dataspace object containing selection to
iterate over
size_t elmt_size; IN: Size of elements in the selection
+ unsigned flags; IN: Flags to control iteration behavior
RETURNS
Non-negative on success, negative on failure.
DESCRIPTION
@@ -1069,7 +1067,8 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset)
in the dataspace's selection.
--------------------------------------------------------------------------*/
herr_t
-H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_size)
+H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space,
+ size_t elmt_size, unsigned flags)
{
herr_t ret_value = FAIL; /* Return value */
@@ -1084,21 +1083,27 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_s
/* Save the dataspace's rank */
sel_iter->rank = space->extent.rank;
- /* Point to the dataspace dimensions, if there are any */
- if(sel_iter->rank > 0)
- sel_iter->dims = space->extent.size;
- else
- sel_iter->dims = NULL;
+ /* If dims > 0, copy the dataspace dimensions & selection offset */
+ if(sel_iter->rank > 0) {
+ H5MM_memcpy(sel_iter->dims, space->extent.size, sizeof(hsize_t) * space->extent.rank);
+ H5MM_memcpy(sel_iter->sel_off, space->select.offset, sizeof(hsize_t) * space->extent.rank);
+ } /* end if */
/* Save the element size */
sel_iter->elmt_size = elmt_size;
+ /* Initialize the number of elements to iterate over */
+ sel_iter->elmt_left = space->select.num_elem;
+
+ /* Set the flags for the iterator */
+ sel_iter->flags = flags;
+
/* Call initialization routine for selection type */
- ret_value = (*space->select.type->iter_init)(sel_iter, space);
+ ret_value = (*space->select.type->iter_init)(space, sel_iter);
HDassert(sel_iter->type);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_init() */
+} /* end H5S_select_iter_init() */
/*--------------------------------------------------------------------------
@@ -1135,10 +1140,10 @@ H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords)
HDassert(coords);
/* Call iter_coords routine for selection type */
- ret_value = (*sel_iter->type->iter_coords)(sel_iter,coords);
+ ret_value = (*sel_iter->type->iter_coords)(sel_iter, coords);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_coords() */
+} /* end H5S_select_iter_coords() */
#ifdef LATER
@@ -1170,7 +1175,7 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
{
herr_t ret_value; /* return value */
- FUNC_ENTER_NOAPI_NOINIT_NOINIT_NOERR
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check args */
HDassert(iter);
@@ -1178,10 +1183,10 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
HDassert(end);
/* Call iter_block routine for selection type */
- ret_value = (*iter->type->iter_block)(iter,start,end);
+ ret_value = (*iter->type->iter_block)(iter, start, end);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_block() */
+} /* end H5S_select_iter_block() */
#endif /* LATER */
@@ -1219,7 +1224,7 @@ H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter)
ret_value = (*sel_iter->type->iter_nelmts)(sel_iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_nelmts() */
+} /* end H5S_select_iter_nelmts() */
#ifdef LATER
@@ -1249,7 +1254,7 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter)
{
herr_t ret_value; /* return value */
- FUNC_ENTER_NOAPI_NOINIT_NOINIT_NOERR
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check args */
HDassert(iter);
@@ -1258,7 +1263,7 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter)
ret_value = (*iter->type->iter_has_next_block)(iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_has_next_block() */
+} /* end H5S_select_iter_has_next_block() */
#endif /* LATER */
@@ -1296,13 +1301,13 @@ H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem)
HDassert(nelem>0);
/* Call iter_next routine for selection type */
- ret_value = (*iter->type->iter_next)(iter,nelem);
+ ret_value = (*iter->type->iter_next)(iter, nelem);
/* Decrement the number of elements left in selection */
iter->elmt_left-=nelem;
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_next() */
+} /* end H5S_select_iter_next() */
#ifdef LATER
@@ -1343,17 +1348,54 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter)
ret_value = (*iter->type->iter_next_block)(iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_next_block() */
+} /* end H5S_select_iter_next_block() */
#endif /* LATER */
+/*-------------------------------------------------------------------------
+ * Function: H5S_select_iter_get_seq_list
+ *
+ * Purpose: Retrieves the next sequence of offset/length pairs for an
+ * iterator on a dataspace
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, May 18, 2004
+ *
+ * Note: This routine participates in the "Inlining C function pointers"
+ * pattern, don't call it directly, use the appropriate macro
+ * defined in H5Sprivate.h.
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelmts,
+ size_t *nseq, size_t *nelmts, hsize_t *off, size_t *len)
+{
+ herr_t ret_value = FAIL; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Sanity check */
+ HDassert(iter);
+
+ /* Call the selection type's get_seq_list function */
+ if((ret_value = (*iter->type->iter_get_seq_list)(iter, maxseq, maxelmts, nseq, nelmts, off, len)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S_select_iter_get_seq_list() */
+
+
/*--------------------------------------------------------------------------
NAME
H5S_select_iter_release
PURPOSE
Release a selection iterator's resources.
USAGE
- hssize_t H5S_select_iter_release(sel_iter)
+ herr_t H5S_select_iter_release(sel_iter)
H5S_sel_iter_t *sel_iter; IN: Selection iterator to query
RETURNS
The number of elements in selection on success, 0 on failure
@@ -1381,7 +1423,7 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter)
ret_value = (*sel_iter->type->iter_release)(sel_iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_iter_release() */
+} /* end H5S_select_iter_release() */
/*--------------------------------------------------------------------------
@@ -1421,7 +1463,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
hsize_t *off = NULL; /* Array to store sequence offsets */
size_t *len = NULL; /* Array to store sequence lengths */
hssize_t nelmts; /* Number of elements in selection */
- hsize_t space_size[H5O_LAYOUT_NDIMS]; /* Dataspace size */
+ hsize_t space_size[H5S_MAX_RANK]; /* Dataspace size */
size_t max_elem; /* Maximum number of elements allowed in sequences */
size_t elmt_size; /* Datatype size */
unsigned ndims; /* Number of dimensions in dataspace */
@@ -1445,7 +1487,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
/* Initialize iterator */
- if(H5S_select_iter_init(iter, space, elmt_size) < 0)
+ if(H5S_select_iter_init(iter, space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
iter_init = TRUE; /* Selection iteration info has been initialized */
@@ -1459,7 +1501,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
if(ndims > 0) {
/* Copy the size of the space */
HDassert(space->extent.size);
- HDmemcpy(space_size, space->extent.size, ndims * sizeof(hsize_t));
+ H5MM_memcpy(space_size, space->extent.size, ndims * sizeof(hsize_t));
} /* end if */
space_size[ndims] = elmt_size;
@@ -1479,7 +1521,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
size_t curr_seq; /* Current sequence being worked on */
/* Get the sequences of bytes */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -1495,7 +1537,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
/* Loop, while bytes left in sequence */
while(curr_len > 0 && user_ret == 0) {
- hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of element in dataspace */
+ hsize_t coords[H5S_MAX_RANK]; /* Coordinates of element in dataspace */
hsize_t tmp_off; /* Temporary offset within sequence */
uint8_t *loc; /* Current element location in buffer */
int i; /* Local Index variable */
@@ -1558,7 +1600,7 @@ done:
iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_select_iterate() */
+} /* end H5S_select_iterate() */
/*--------------------------------------------------------------------------
@@ -1594,7 +1636,7 @@ H5Sget_select_type(hid_t space_id)
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Sget_select_type() */
+} /* end H5Sget_select_type() */
/*--------------------------------------------------------------------------
@@ -1616,7 +1658,7 @@ done:
pattern, don't call it directly, use the appropriate macro
defined in H5Sprivate.h.
--------------------------------------------------------------------------*/
-H5S_sel_type
+H5_ATTR_PURE H5S_sel_type
H5S_get_select_type(const H5S_t *space)
{
H5S_sel_type ret_value = H5S_SEL_ERROR; /* Return value */
@@ -1627,10 +1669,10 @@ H5S_get_select_type(const H5S_t *space)
HDassert(space);
/* Set return value */
- ret_value=H5S_GET_SELECT_TYPE(space);
+ ret_value = H5S_GET_SELECT_TYPE(space);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_get_select_type() */
+} /* end H5S_get_select_type() */
/*--------------------------------------------------------------------------
@@ -1650,20 +1692,17 @@ H5S_get_select_type(const H5S_t *space)
This is primarily used for reading the entire selection in one swoop.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
- Assumes that there is only a single "block" for hyperslab selections.
EXAMPLES
REVISION LOG
- Modified function to view identical shapes with different dimensions
- as being the same under some circumstances.
--------------------------------------------------------------------------*/
htri_t
H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
{
H5S_sel_iter_t *iter_a = NULL; /* Selection a iteration info */
H5S_sel_iter_t *iter_b = NULL; /* Selection b iteration info */
- hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */
- hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */
- htri_t ret_value = TRUE; /* Return value */
+ hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */
+ hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */
+ htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1684,124 +1723,98 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
const H5S_t *space_b; /* Dataspace with smaller rank */
unsigned space_a_rank; /* Number of dimensions of dataspace A */
unsigned space_b_rank; /* Number of dimensions of dataspace B */
+ int space_a_dim; /* Current dimension in dataspace A */
+ int space_b_dim; /* Current dimension in dataspace B */
+ H5S_sel_type sel_a_type; /* Selection type for dataspace A */
+ H5S_sel_type sel_b_type; /* Selection type for dataspace B */
- /* need to be able to handle spaces of different rank:
+ /* Need to be able to handle spaces of different rank:
*
* To simplify logic, let space_a point to the element of the set
- * {space1, space2} with the largest rank or space1 if the ranks
+ * {space1, space2} with the largest rank or space1 if the ranks
* are identical.
*
* Similarly, let space_b point to the element of {space1, space2}
* with the smallest rank, or space2 if they are identical.
*
- * Let: space_a_rank be the rank of space_a,
+ * Let: space_a_rank be the rank of space_a,
* space_b_rank be the rank of space_b,
- * delta_rank = space_a_rank - space_b_rank.
*
- * Set all this up below.
+ * Set all this up here.
*/
if(space1->extent.rank >= space2->extent.rank) {
space_a = space1;
- space_a_rank = space_a->extent.rank;
-
space_b = space2;
- space_b_rank = space_b->extent.rank;
} /* end if */
else {
space_a = space2;
- space_a_rank = space_a->extent.rank;
-
space_b = space1;
- space_b_rank = space_b->extent.rank;
} /* end else */
+ space_a_rank = space_a->extent.rank;
+ space_b_rank = space_b->extent.rank;
HDassert(space_a_rank >= space_b_rank);
HDassert(space_b_rank > 0);
- /* Check for "easy" cases before getting into generalized block iteration code */
- if((H5S_GET_SELECT_TYPE(space_a) == H5S_SEL_ALL) && (H5S_GET_SELECT_TYPE(space_b) == H5S_SEL_ALL)) {
- hsize_t dims1[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #1 */
- hsize_t dims2[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #2 */
- int space_a_dim; /* Current dimension in dataspace A */
- int space_b_dim; /* Current dimension in dataspace B */
+ /* Get selection type for both dataspaces */
+ sel_a_type = H5S_GET_SELECT_TYPE(space_a);
+ sel_b_type = H5S_GET_SELECT_TYPE(space_b);
- if(H5S_get_simple_extent_dims(space_a, dims1, NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality")
- if(H5S_get_simple_extent_dims(space_b, dims2, NULL) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality")
+ /* If selections aren't "none", compare their bounds */
+ if(sel_a_type != H5S_SEL_NONE && sel_b_type != H5S_SEL_NONE) {
+ hsize_t low_a[H5S_MAX_RANK]; /* Low bound of selection in dataspace a */
+ hsize_t low_b[H5S_MAX_RANK]; /* Low bound of selection in dataspace b */
+ hsize_t high_a[H5S_MAX_RANK]; /* High bound of selection in dataspace a */
+ hsize_t high_b[H5S_MAX_RANK]; /* High bound of selection in dataspace b */
- space_a_dim = (int)space_a_rank - 1;
- space_b_dim = (int)space_b_rank - 1;
-
- /* recall that space_a_rank >= space_b_rank.
- *
- * In the following while loop, we test to see if space_a and space_b
- * have identical size in all dimensions they have in common.
- */
- while(space_b_dim >= 0) {
- if(dims1[space_a_dim] != dims2[space_b_dim])
- HGOTO_DONE(FALSE)
-
- space_a_dim--;
- space_b_dim--;
- } /* end while */
-
- /* Since we are selecting the entire space, we must also verify that space_a
- * has size 1 in all dimensions that it does not share with space_b.
- */
- while(space_a_dim >= 0) {
- if(dims1[space_a_dim] != 1)
- HGOTO_DONE(FALSE)
-
- space_a_dim--;
- } /* end while */
- } /* end if */
- else if((H5S_GET_SELECT_TYPE(space1) == H5S_SEL_NONE) || (H5S_GET_SELECT_TYPE(space2) == H5S_SEL_NONE)) {
- /* (Both must be, at this point, if one is) */
- HGOTO_DONE(TRUE)
- } /* end if */
- else if((H5S_GET_SELECT_TYPE(space_a) == H5S_SEL_HYPERSLABS && space_a->select.sel_info.hslab->diminfo_valid)
- && (H5S_GET_SELECT_TYPE(space_b) == H5S_SEL_HYPERSLABS && space_b->select.sel_info.hslab->diminfo_valid)) {
- int space_a_dim; /* Current dimension in dataspace A */
- int space_b_dim; /* Current dimension in dataspace B */
+ /* Get low & high bounds for both dataspaces */
+ if(H5S_SELECT_BOUNDS(space_a, low_a, high_a) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for first dataspace")
+ if(H5S_SELECT_BOUNDS(space_b, low_b, high_b) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for second dataspace")
+ /* Check that the range between the low & high bounds are the same */
space_a_dim = (int)space_a_rank - 1;
space_b_dim = (int)space_b_rank - 1;
-
- /* check that the shapes are the same in the common dimensions, and that
- * block == 1 in all dimensions that appear only in space_a.
- */
while(space_b_dim >= 0) {
- if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].stride !=
- space_b->select.sel_info.hslab->opt_diminfo[space_b_dim].stride)
- HGOTO_DONE(FALSE)
+ /* Sanity check */
+ HDassert(low_a[space_a_dim] <= high_a[space_a_dim]);
+ HDassert(low_a[space_b_dim] <= high_a[space_b_dim]);
- if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].count !=
- space_b->select.sel_info.hslab->opt_diminfo[space_b_dim].count)
- HGOTO_DONE(FALSE)
-
- if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].block !=
- space_b->select.sel_info.hslab->opt_diminfo[space_b_dim].block)
+ /* Verify that the ranges are the same */
+ if((high_a[space_a_dim] - low_a[space_a_dim])
+ != (high_b[space_b_dim] - low_b[space_b_dim]))
HGOTO_DONE(FALSE)
+ /* Go to next dimension */
space_a_dim--;
space_b_dim--;
} /* end while */
+ /* Check that the rest of the ranges in space a are "flat" */
while(space_a_dim >= 0) {
- if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].block != 1)
+ /* Sanity check */
+ HDassert(low_a[space_a_dim] <= high_a[space_a_dim]);
+
+ /* This range should be flat to be the same in a lower dimension */
+ if(low_a[space_a_dim] != high_a[space_a_dim])
HGOTO_DONE(FALSE)
space_a_dim--;
} /* end while */
} /* end if */
- /* Iterate through all the blocks in the selection */
+
+ /* If the dataspaces have the same selection type, use the selection's
+ * shape_same operator.
+ */
+ if(sel_a_type == sel_b_type)
+ ret_value = (*space_a->select.type->shape_same)(space_a, space_b);
+ /* Otherwise, iterate through all the blocks in the selection */
else {
hsize_t start_a[H5S_MAX_RANK]; /* Start point of selection block in dataspace a */
hsize_t start_b[H5S_MAX_RANK]; /* Start point of selection block in dataspace b */
hsize_t end_a[H5S_MAX_RANK]; /* End point of selection block in dataspace a */
hsize_t end_b[H5S_MAX_RANK]; /* End point of selection block in dataspace b */
- hsize_t off_a[H5S_MAX_RANK]; /* Offset of selection a blocks */
- hsize_t off_b[H5S_MAX_RANK]; /* Offset of selection b blocks */
+ hssize_t offset[H5S_MAX_RANK]; /* Offset of selection b blocks relative to selection a blocks */
hbool_t first_block = TRUE; /* Flag to indicate the first block */
/* Allocate the selection iterators */
@@ -1815,17 +1828,15 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
* that the selection iterator shouldn't be "flattened", since we
* aren't actually going to be doing I/O with the iterators.
*/
- if(H5S_select_iter_init(iter_a, space_a, (size_t)0) < 0)
+ if(H5S_select_iter_init(iter_a, space_a, (size_t)0, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator a")
iter_a_init = TRUE;
- if(H5S_select_iter_init(iter_b, space_b, (size_t)0) < 0)
+ if(H5S_select_iter_init(iter_b, space_b, (size_t)0, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator b")
iter_b_init = TRUE;
/* Iterate over all the blocks in each selection */
while(1) {
- int space_a_dim; /* Current dimension in dataspace A */
- int space_b_dim; /* Current dimension in dataspace B */
htri_t status_a, status_b; /* Status from next block checks */
/* Get the current block for each selection iterator */
@@ -1837,11 +1848,11 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
space_a_dim = (int)space_a_rank - 1;
space_b_dim = (int)space_b_rank - 1;
- /* The first block only compares the sizes and sets the
- * relative offsets for later blocks
+ /* The first block only compares the sizes and sets the
+ * relative offsets for later blocks
*/
if(first_block) {
- /* If the block sizes in the common dimensions from
+ /* If the block sizes in the common dimensions from
* each selection don't match, get out
*/
while(space_b_dim >= 0) {
@@ -1850,23 +1861,19 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
HGOTO_DONE(FALSE)
/* Set the relative locations of the selections */
- off_a[space_a_dim] = start_a[space_a_dim];
- off_b[space_b_dim] = start_b[space_b_dim];
+ offset[space_a_dim] = (hssize_t)start_b[space_b_dim] - (hssize_t)start_a[space_a_dim];
space_a_dim--;
space_b_dim--;
} /* end while */
- /* similarly, if the block size in any dimension that appears only
+ /* Similarly, if the block size in any dimension that appears only
* in space_a is not equal to 1, get out.
*/
while(space_a_dim >= 0) {
- if((end_a[space_a_dim] - start_a[space_a_dim]) != 0)
+ if(start_a[space_a_dim] != end_a[space_a_dim])
HGOTO_DONE(FALSE)
- /* Set the relative locations of the selections */
- off_a[space_a_dim] = start_a[space_a_dim];
-
space_a_dim--;
} /* end while */
@@ -1875,11 +1882,10 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
} /* end if */
/* Check over the blocks for each selection */
else {
- /* for dimensions that space_a and space_b have in common: */
+ /* For dimensions that space_a and space_b have in common: */
while(space_b_dim >= 0) {
/* Check if the blocks are in the same relative location */
- if((start_a[space_a_dim] - off_a[space_a_dim]) !=
- (start_b[space_b_dim] - off_b[space_b_dim]))
+ if((hsize_t)((hssize_t)start_a[space_a_dim] + offset[space_a_dim]) != start_b[space_b_dim])
HGOTO_DONE(FALSE)
/* If the block sizes from each selection doesn't match, get out */
@@ -1894,7 +1900,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
/* For dimensions that appear only in space_a: */
while(space_a_dim >= 0) {
/* If the block size isn't 1, get out */
- if((end_a[space_a_dim] - start_a[space_a_dim]) != 0)
+ if(start_a[space_a_dim] != end_a[space_a_dim])
HGOTO_DONE(FALSE)
space_a_dim--;
@@ -1936,7 +1942,7 @@ done:
iter_b = H5FL_FREE(H5S_sel_iter_t, iter_b);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_shape_same() */
+} /* end H5S_select_shape_same() */
/*--------------------------------------------------------------------------
@@ -1945,24 +1951,24 @@ done:
PURPOSE
Given a dataspace a of rank n with some selection, construct a new
- dataspace b of rank m (m != n), with the selection in a being
- topologically identical to that in b (as verified by
+ dataspace b of rank m (m != n), with the selection in a being
+ topologically identical to that in b (as verified by
H5S_select_shape_same().
- This function exists, as some I/O code chokes on topologically
- identical selections with different ranks. At least to begin
+ This function exists, as some I/O code chokes on topologically
+ identical selections with different ranks. At least to begin
with, we will deal with the issue by constructing projections
- of the memory dataspace with ranks equaling those of the file
+ of the memory dataspace with ranks equaling those of the file
dataspace.
- Note that if m > n, it is possible that the starting point in the
- buffer associated with the memory dataspace will have to be
+ Note that if m > n, it is possible that the starting point in the
+ buffer associated with the memory dataspace will have to be
adjusted to match the projected dataspace. If the buf parameter
is not NULL, the function must return an adjusted buffer base
address in *adj_buf_ptr.
USAGE
- htri_t H5S_select_construct_projection(base_space,
+ htri_t H5S_select_construct_projection(base_space,
new_space_ptr,
new_space_rank,
buf,
@@ -1971,30 +1977,30 @@ done:
H5S_t ** new_space_ptr; OUT: Ptr to location in which to return
the address of the projected space
int new_space_rank; IN: Rank of the projected space.
- const void * buf; IN: Base address of the buffer
+ const void * buf; IN: Base address of the buffer
associated with the base space.
May be NULL.
void ** adj_buf_ptr; OUT: If buf != NULL, store the base
- address of the section of buf
+ address of the section of buf
that is described by *new_space_ptr
in *adj_buf_ptr.
-
+
RETURNS
Non-negative on success/Negative on failure.
DESCRIPTION
- Construct a new dataspace and associated selection which is a
- projection of the supplied dataspace and associated selection into
+ Construct a new dataspace and associated selection which is a
+ projection of the supplied dataspace and associated selection into
the specified rank. Return it in *new_space_ptr.
- If buf is supplied, computes the base address of the projected
+ If buf is supplied, computes the base address of the projected
selection in buf, and stores the base address in *adj_buf_ptr.
-
+
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
- The selection in the supplied base_space has thickness 1 in all
+ The selection in the supplied base_space has thickness 1 in all
dimensions greater than new_space_rank. Note that here we count
- dimensions from the fastest changing coordinate to the slowest
+ dimensions from the fastest changing coordinate to the slowest
changing changing coordinate.
EXAMPLES
REVISION LOG
@@ -2040,28 +2046,28 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr,
/* Create new scalar dataspace */
if(NULL == (new_space = H5S_create(H5S_SCALAR)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create scalar dataspace")
-
+
/* No need to register the dataspace(i.e. get an ID) as
* we will just be discarding it shortly.
*/
- /* Selection for the new space will be either all or
+ /* Selection for the new space will be either all or
* none, depending on whether the base space has 0 or
* 1 elements selected.
*
- * Observe that the base space can't have more than
+ * Observe that the base space can't have more than
* one selected element, since its selection has the
- * same shape as the file dataspace, and that data
+ * same shape as the file dataspace, and that data
* space is scalar.
*/
if(1 == npoints) {
/* Assuming that the selection in the base dataspace is not
- * empty, we must compute the offset of the selected item in
+ * empty, we must compute the offset of the selected item in
* the buffer associated with the base dataspace.
*
- * Since the new space rank is zero, we know that the
- * the base space must have rank at least 1 -- and
- * hence it is a simple dataspace. However, the
+ * Since the new space rank is zero, we know that the
+ * the base space must have rank at least 1 -- and
+ * hence it is a simple dataspace. However, the
* selection, may be either point, hyperspace, or all.
*
*/
@@ -2079,25 +2085,25 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr,
hsize_t new_space_dims[H5S_MAX_RANK]; /* Current dimensions for new dataspace */
hsize_t new_space_maxdims[H5S_MAX_RANK];/* Maximum dimensions for new dataspace */
unsigned rank_diff; /* Difference in ranks */
-
+
/* Set up the dimensions of the new, projected dataspace.
*
- * How we do this depends on whether we are projecting up into
- * increased dimensions, or down into a reduced number of
+ * How we do this depends on whether we are projecting up into
+ * increased dimensions, or down into a reduced number of
* dimensions.
*
- * If we are projecting up (the first half of the following
- * if statement), we copy the dimensions of the base data
- * space into the fastest changing dimensions of the new
+ * If we are projecting up (the first half of the following
+ * if statement), we copy the dimensions of the base data
+ * space into the fastest changing dimensions of the new
* projected dataspace, and set the remaining dimensions to
* one.
*
* If we are projecting down (the second half of the following
- * if statement), we just copy the dimensions with the most
+ * if statement), we just copy the dimensions with the most
* quickly changing dimensions into the dims for the projected
* data set.
*
- * This works, because H5S_select_shape_same() will return
+ * This works, because H5S_select_shape_same() will return
* true on selections of different rank iff:
*
* 1) the selection in the lower rank dataspace matches that
@@ -2105,37 +2111,37 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr,
* the larger rank dataspace, and
*
* 2) the selection has thickness 1 in all ranks that appear
- * only in the higher rank dataspace (i.e. those with
+ * only in the higher rank dataspace (i.e. those with
* more slowly changing indicies).
- */
+ */
if(new_space_rank > base_space_rank) {
hsize_t tmp_dim_size = 1; /* Temporary dimension value, for filling arrays */
- /* we must copy the dimensions of the base space into
+ /* we must copy the dimensions of the base space into
* the fastest changing dimensions of the new space,
* and set the remaining dimensions to 1
*/
rank_diff = new_space_rank - base_space_rank;
H5VM_array_fill(new_space_dims, &tmp_dim_size, sizeof(tmp_dim_size), rank_diff);
H5VM_array_fill(new_space_maxdims, &tmp_dim_size, sizeof(tmp_dim_size), rank_diff);
- HDmemcpy(&new_space_dims[rank_diff], base_space_dims, sizeof(new_space_dims[0]) * base_space_rank);
- HDmemcpy(&new_space_maxdims[rank_diff], base_space_maxdims, sizeof(new_space_maxdims[0]) * base_space_rank);
+ H5MM_memcpy(&new_space_dims[rank_diff], base_space_dims, sizeof(new_space_dims[0]) * base_space_rank);
+ H5MM_memcpy(&new_space_maxdims[rank_diff], base_space_maxdims, sizeof(new_space_maxdims[0]) * base_space_rank);
} /* end if */
else { /* new_space_rank < base_space_rank */
- /* we must copy the fastest changing dimension of the
+ /* we must copy the fastest changing dimension of the
* base space into the dimensions of the new space.
*/
rank_diff = base_space_rank - new_space_rank;
- HDmemcpy(new_space_dims, &base_space_dims[rank_diff], sizeof(new_space_dims[0]) * new_space_rank);
- HDmemcpy(new_space_maxdims, &base_space_maxdims[rank_diff], sizeof(new_space_maxdims[0]) * new_space_rank);
+ H5MM_memcpy(new_space_dims, &base_space_dims[rank_diff], sizeof(new_space_dims[0]) * new_space_rank);
+ H5MM_memcpy(new_space_maxdims, &base_space_maxdims[rank_diff], sizeof(new_space_maxdims[0]) * new_space_rank);
} /* end else */
- /* now have the new space rank and dimensions set up --
+ /* now have the new space rank and dimensions set up --
* so we can create the new simple dataspace.
*/
if(NULL == (new_space = H5S_create_simple(new_space_rank, new_space_dims, new_space_maxdims)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
-
+
/* No need to register the dataspace(i.e. get an ID) as
* we will just be discarding it shortly.
*/
@@ -2146,22 +2152,22 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr,
*/
if(H5S_SELECT_PROJECT_SIMPLE(base_space, new_space, &projected_space_element_offset) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to project simple selection")
-
+
/* If we get this far, we have created the new dataspace, and projected
* the selection in the base dataspace into the new dataspace.
*
- * If the base dataspace is simple, check to see if the
- * offset_changed flag on the base selection has been set -- if so,
- * project the offset into the new dataspace and set the
+ * If the base dataspace is simple, check to see if the
+ * offset_changed flag on the base selection has been set -- if so,
+ * project the offset into the new dataspace and set the
* offset_changed flag.
*/
if(H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE && base_space->select.offset_changed) {
if(new_space_rank > base_space_rank) {
HDmemset(new_space->select.offset, 0, sizeof(new_space->select.offset[0]) * rank_diff);
- HDmemcpy(&new_space->select.offset[rank_diff], base_space->select.offset, sizeof(new_space->select.offset[0]) * base_space_rank);
+ H5MM_memcpy(&new_space->select.offset[rank_diff], base_space->select.offset, sizeof(new_space->select.offset[0]) * base_space_rank);
} /* end if */
else
- HDmemcpy(new_space->select.offset, &base_space->select.offset[rank_diff], sizeof(new_space->select.offset[0]) * new_space_rank);
+ H5MM_memcpy(new_space->select.offset, &base_space->select.offset[rank_diff], sizeof(new_space->select.offset[0]) * new_space_rank);
/* Propagate the offset changed flag into the new dataspace. */
new_space->select.offset_changed = TRUE;
@@ -2184,12 +2190,12 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr,
* Since we can't do pointer arithmetic on void pointers, we first
* cast buf to a pointer to byte -- i.e. uint8_t.
*
- * We then multiply the projected space element offset we
- * calculated earlier by the supplied element size, add this
- * value to the type cast buf pointer, cast the result back
+ * We then multiply the projected space element offset we
+ * calculated earlier by the supplied element size, add this
+ * value to the type cast buf pointer, cast the result back
* to a pointer to void, and assign the result to *adj_buf_ptr.
*/
- *adj_buf_ptr = (const void *)(((const uint8_t *)buf) +
+ *adj_buf_ptr = (const void *)(((const uint8_t *)buf) +
((size_t)(projected_space_element_offset * element_size)));
} /* end if */
else
@@ -2204,7 +2210,7 @@ done:
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_construct_projection() */
+} /* end H5S_select_construct_projection() */
/*--------------------------------------------------------------------------
@@ -2235,7 +2241,7 @@ herr_t
H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_buf)
{
H5S_sel_iter_t *iter = NULL; /* Selection iteration info */
- hbool_t iter_init = 0; /* Selection iteration info has been initialized */
+ hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */
hsize_t *off = NULL; /* Array to store sequence offsets */
size_t *len = NULL; /* Array to store sequence lengths */
hssize_t nelmts; /* Number of elements in selection */
@@ -2255,9 +2261,9 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
/* Initialize iterator */
- if(H5S_select_iter_init(iter, space, fill_size) < 0)
+ if(H5S_select_iter_init(iter, space, fill_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
- iter_init = 1; /* Selection iteration info has been initialized */
+ iter_init = TRUE; /* Selection iteration info has been initialized */
/* Get the number of elements in selection */
if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0)
@@ -2279,7 +2285,7 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b
size_t nelem; /* Number of elements used in sequences */
/* Get the sequences of bytes */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Loop over sequences */
@@ -2312,7 +2318,7 @@ done:
iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_fill() */
+} /* end H5S_select_fill() */
/*--------------------------------------------------------------------------
@@ -2339,7 +2345,7 @@ done:
src_intersect_space within the selection of src_space as a selection
within the selection of dst_space. The result is placed in the
selection of new_space_ptr.
-
+
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
@@ -2363,7 +2369,7 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
/* 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")
- if(H5S_extent_copy_real(&new_space->extent, &dst_space->extent, TRUE) < 0)
+ if(H5S__extent_copy_real(&new_space->extent, &dst_space->extent, TRUE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy destination space extent")
/* If the intersecting space is "all", the intersection must be equal to the
@@ -2373,22 +2379,25 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
if(H5S_select_copy(new_space, dst_space, FALSE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination space selection")
} /* end if */
- /* If any of the spaces are "none", the projection must also be "none" */
- else if((src_intersect_space->select.type->type == H5S_SEL_NONE)
- || (src_space->select.type->type == H5S_SEL_NONE)
- || (dst_space->select.type->type == H5S_SEL_NONE)) {
+ /* If any of the selections contain no elements, the projection must be
+ * "none" */
+ else if((H5S_GET_SELECT_NPOINTS(src_intersect_space) == 0)
+ || (H5S_GET_SELECT_NPOINTS(src_space) == 0)
+ || (H5S_GET_SELECT_NPOINTS(dst_space) == 0)) {
/* Change to "none" selection */
if(H5S_select_none(new_space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
} /* end if */
- /* If any of the spaces use point selection, fall back to general algorithm
- */
+ /* If any of the spaces use point selection, fall back to general algorithm */
else if((src_intersect_space->select.type->type == H5S_SEL_POINTS)
|| (src_space->select.type->type == H5S_SEL_POINTS)
|| (dst_space->select.type->type == H5S_SEL_POINTS))
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
else {
HDassert(src_intersect_space->select.type->type == H5S_SEL_HYPERSLABS);
+ HDassert(src_space->select.type->type != H5S_SEL_NONE);
+ HDassert(dst_space->select.type->type != H5S_SEL_NONE);
+
/* Intersecting space is hyperslab selection. Call the hyperslab
* routine to project to another hyperslab selection. */
if(H5S__hyper_project_intersection(src_space, dst_space, src_intersect_space, new_space) < 0)
@@ -2405,7 +2414,7 @@ done:
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_project_intersection() */
+} /* end H5S_select_project_intersection() */
/*--------------------------------------------------------------------------
@@ -2427,7 +2436,7 @@ done:
Removes any and all portions of space that are also present in
subtract_space. In essence, performs an A_NOT_B operation with the
two selections.
-
+
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
@@ -2454,12 +2463,13 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space)
if(H5S_select_none(space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
} /* end if */
+ /* If either selection is a point selection, fail currently */
+ else if((subtract_space->select.type->type == H5S_SEL_POINTS) ||
+ (space->select.type->type == H5S_SEL_POINTS)) {
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
+ } /* end if */
else {
- /* Check for point selection in subtract_space, convert to hyperslab */
- if(subtract_space->select.type->type == H5S_SEL_POINTS)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
-
- /* Check for point or all selection in space, convert to hyperslab */
+ /* Check for all selection in space, convert to hyperslab */
if(space->select.type->type == H5S_SEL_ALL) {
/* Convert current "all" selection to "real" hyperslab selection */
/* Then allow operation to proceed */
@@ -2481,19 +2491,231 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space)
if(H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection")
} /* end if */
- else if(space->select.type->type == H5S_SEL_POINTS)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
HDassert(space->select.type->type == H5S_SEL_HYPERSLABS);
HDassert(subtract_space->select.type->type == H5S_SEL_HYPERSLABS);
/* Both spaces are now hyperslabs, perform the operation */
- if(H5S__hyper_subtract(space, subtract_space) < 0)
+ if(H5S__modify_select(space, H5S_SELECT_NOTB, subtract_space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't subtract hyperslab")
} /* end else */
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_select_subtract() */
+} /* end H5S_select_subtract() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Ssel_iter_create
+ PURPOSE
+ Create a dataspace selection iterator for a dataspace's selection
+ USAGE
+ hid_t H5Ssel_iter_create(space)
+ hid_t space; IN: ID of the dataspace with selection to iterate over
+ RETURNS
+ Valid dataspace selection iterator ID on success, H5I_INVALID_HID on failure
+ DESCRIPTION
+ Creates a selection iterator and initializes it to start at the first
+ element selected in the dataspace.
+ PROGRAMMER
+ Quincey Koziol - February 11, 2019
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+hid_t
+H5Ssel_iter_create(hid_t space_id, size_t elmt_size, unsigned flags)
+{
+ H5S_t *space; /* Dataspace with selection to iterate over */
+ H5S_sel_iter_t *sel_iter; /* Selection iterator created */
+ hid_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(H5I_INVALID_HID)
+ H5TRACE3("i", "izIu", space_id, elmt_size, flags);
+
+ /* Check args */
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace")
+ if(elmt_size == 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, H5I_INVALID_HID, "element size must be greater than 0")
+ if(flags != (flags & H5S_SEL_ITER_ALL_PUBLIC_FLAGS))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, H5I_INVALID_HID, "invalid selection iterator flag")
+
+ /* Allocate the iterator */
+ if(NULL == (sel_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate selection iterator")
+
+ /* Add flag to indicate that this iterator is from an API call */
+ flags |= H5S_SEL_ITER_API_CALL;
+
+ /* Initialize the selection iterator */
+ if(H5S_select_iter_init(sel_iter, space, elmt_size, flags) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to initialize selection iterator")
+
+ /* Atomize */
+ if((ret_value = H5I_register(H5I_SPACE_SEL_ITER, sel_iter, TRUE)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace selection iterator atom")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Ssel_iter_create() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Ssel_iter_get_seq_list
+ PURPOSE
+ Retrieve a list of offset / length sequences for the elements in an iterator
+ USAGE
+ herr_t H5Ssel_iter_get_seq_list(sel_iter_id, maxseq, maxbytes, nseq, nbytes, off, len)
+ hid_t sel_iter_id; IN: ID of the dataspace selection iterator to retrieve sequence from
+ size_t maxseq; IN: Max. # of sequences to retrieve
+ size_t maxbytes; IN: Max. # of bytes to retrieve in sequences
+ size_t *nseq; OUT: # of sequences retrieved
+ size_t *nbytes; OUT: # of bytes retrieved, in all sequences
+ hsize_t *off; OUT: Array of sequence offsets
+ size_t *len; OUT: Array of sequence lengths
+ RETURNS
+ Non-negative on success / Negative on failure
+ DESCRIPTION
+ Retrieve a list of offset / length pairs (a list of "sequences") matching
+ the selected elements for an iterator, according to the iteration order for
+ the iterator. The lengths returned are in _bytes_, not elements.
+
+ Note that the iteration order for "all" and "hyperslab" selections is
+ row-major (i.e. "C-ordered"), but the iteration order for "point"
+ selections is "in order selected", unless the H5S_SEL_ITER_GET_SEQ_LIST_SORTED
+ flag is passed to H5Sset_iter_create for a point selection.
+
+ MAXSEQ and MAXBYTES specify the most sequences or bytes possible to
+ place into the OFF and LEN arrays. *NSEQ and *NBYTES return the actual
+ number of sequences and bytes put into the arrays.
+
+ Each call to H5Ssel_iter_get_seq_list() will retrieve the next set
+ of sequences for the selection being iterated over.
+
+ The total number of bytes possible to retrieve from a selection iterator
+ is the 'elmt_size' passed to H5Ssel_iter_create multiplied by the number
+ of elements selected in the dataspace the iterator was created from
+ (which can be retrieved with H5Sget_select_npoints). When there are no
+ further sequences of elements to retrieve, calls to this routine will
+ set *NSEQ and *NBYTES to zero.
+ PROGRAMMER
+ Quincey Koziol - February 11, 2019
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Ssel_iter_get_seq_list(hid_t sel_iter_id, size_t maxseq, size_t maxbytes,
+ size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len)
+{
+ H5S_sel_iter_t *sel_iter; /* Dataspace selection iterator to operate on */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE7("e", "izz*z*z*h*z", sel_iter_id, maxseq, maxbytes, nseq, nbytes, off,
+ len);
+
+ /* Check args */
+ if(NULL == (sel_iter = (H5S_sel_iter_t *)H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace selection iterator")
+ if(NULL == nseq)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "'nseq' pointer is NULL")
+ if(NULL == nbytes)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "'nbytes' pointer is NULL")
+ if(NULL == off)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "offset array pointer is NULL")
+ if(NULL == len)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "length array pointer is NULL")
+
+ /* Get the sequences of bytes */
+ if(maxseq > 0 && maxbytes > 0) {
+ if(H5S_SELECT_ITER_GET_SEQ_LIST(sel_iter, maxseq, maxbytes, nseq, nbytes, off, len) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "sequence length generation failed")
+ } /* end if */
+ else
+ *nseq = *nbytes = 0;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Ssel_iter_get_seq_list() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5S_sel_iter_close
+ *
+ * Purpose: Releases a dataspace selection iterator and its memory.
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Monday, February 11, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5S_sel_iter_close(H5S_sel_iter_t *sel_iter)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(sel_iter);
+
+ /* Call selection type-specific release routine */
+ if(H5S_SELECT_ITER_RELEASE(sel_iter) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "problem releasing a selection iterator's type-specific info")
+
+ /* Release the structure */
+ sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S_sel_iter_close() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Ssel_iter_close
+ PURPOSE
+ Close a dataspace selection iterator
+ USAGE
+ herr_t H5Ssel_iter_close(sel_iter_id)
+ hid_t sel_iter_id; IN: ID of the dataspace selection iterator to close
+ RETURNS
+ Non-negative on success / Negative on failure
+ DESCRIPTION
+ Close a dataspace selection iterator, releasing its state.
+ PROGRAMMER
+ Quincey Koziol - February 11, 2019
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Ssel_iter_close(hid_t sel_iter_id)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "i", sel_iter_id);
+
+ /* Check args */
+ if(NULL == H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace selection iterator")
+
+ /* When the reference count reaches zero the resources are freed */
+ if(H5I_dec_app_ref(sel_iter_id) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing dataspace selection iterator ID")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Ssel_iter_close() */