summaryrefslogtreecommitdiffstats
path: root/src/H5S.c
diff options
context:
space:
mode:
authorM. Scot Breitenfeld <brtnfld@hdfgroup.org>2018-06-04 19:41:12 (GMT)
committerM. Scot Breitenfeld <brtnfld@hdfgroup.org>2018-06-04 19:41:12 (GMT)
commitf484649347152316229f607f782ea269ebbc5994 (patch)
tree9f8ffda1440436cbd01b1c34495533c14ea92039 /src/H5S.c
parentcc611c696fbff4731c4eef3882ef985ac3ebab1d (diff)
parentafc6beb7760d2c7ee13f2456deac3da4e1ae4b2e (diff)
downloadhdf5-f484649347152316229f607f782ea269ebbc5994.zip
hdf5-f484649347152316229f607f782ea269ebbc5994.tar.gz
hdf5-f484649347152316229f607f782ea269ebbc5994.tar.bz2
Merge branch 'develop' into hdf5_1_10.sync
Diffstat (limited to 'src/H5S.c')
-rw-r--r--src/H5S.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/src/H5S.c b/src/H5S.c
index b490b36..bd21caf 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -26,7 +26,6 @@
#include "H5Fprivate.h" /* Files */
#include "H5FLprivate.h" /* Free lists */
#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* Object headers */
#include "H5Spkg.h" /* Dataspaces */
@@ -208,6 +207,58 @@ H5S_term_package(void)
FUNC_LEAVE_NOAPI(n)
} /* end H5S_term_package() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_get_validiated_dataspace
+ PURPOSE
+ Get a pointer to a validated H5S_t pointer
+ USAGE
+ H5S_t *H5S_get_validated_space(dataspace_id, space)
+ hid_t space_id; IN: The ID of the dataspace
+ const H5S_t * space; OUT: A pointer to the dataspace
+ RETURNS
+ SUCCEED/FAIL
+ DESCRIPTION
+ Gets a pointer to a dataspace struct after validating it. The pointer
+ can be NULL (if the ID is H5S_ALL, for example).
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ HDassert(space);
+
+ if (space_id < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid space_id (ID cannot be a negative number)")
+
+ if (H5S_ALL == space_id) {
+ /* No special dataspace struct for H5S_ALL */
+ *space = NULL;
+ }
+ else {
+ /* Get the dataspace pointer */
+ if (NULL == (*space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "space_id is not a dataspace ID")
+
+ /* Check for valid selection */
+ if (H5S_SELECT_VALID(*space) != TRUE)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection + offset not within extent")
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+
+} /* end H5S_get_validated_dataspace() */
+
/*--------------------------------------------------------------------------
NAME