summaryrefslogtreecommitdiffstats
path: root/src/H5S.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5S.c')
-rw-r--r--src/H5S.c126
1 files changed, 39 insertions, 87 deletions
diff --git a/src/H5S.c b/src/H5S.c
index 6183a7d..3d09fa0 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/****************/
@@ -59,6 +57,12 @@ static htri_t H5S_is_simple(const H5S_t *sdim);
/* Package initialization variable */
hbool_t H5_PKG_INIT_VAR = FALSE;
+/* Format version bounds for dataspace */
+const unsigned H5O_sdspace_ver_bounds[] = {
+ H5O_SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */
+ H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V18 */
+ H5O_SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */
+};
/*****************************/
/* Library Private Variables */
@@ -86,6 +90,7 @@ static const H5I_class_t H5I_DATASPACE_CLS[1] = {{
(H5I_free_t)H5S_close /* Callback routine for closing objects of this class */
}};
+
/* Flag indicating "top" of interface has been initialized */
static hbool_t H5S_top_package_initialize_s = FALSE;
@@ -1069,7 +1074,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5S_write(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned update_flags, H5S_t *ds)
+H5S_write(H5F_t *f, H5O_t *oh, unsigned update_flags, H5S_t *ds)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -1081,7 +1086,7 @@ H5S_write(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned update_flags, H5S_t *ds)
HDassert(H5S_GET_EXTENT_TYPE(ds) >= 0);
/* Write the current dataspace extent to the dataspace message */
- if(H5O_msg_write_oh(f, dxpl_id, oh, H5O_SDSPACE_ID, 0, update_flags, &(ds->extent)) < 0)
+ if(H5O_msg_write_oh(f, oh, H5O_SDSPACE_ID, 0, update_flags, &(ds->extent)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple dataspace message")
done:
@@ -1110,7 +1115,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5S_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5S_t *ds)
+H5S_append(H5F_t *f, H5O_t *oh, H5S_t *ds)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -1122,7 +1127,7 @@ H5S_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5S_t *ds)
HDassert(H5S_GET_EXTENT_TYPE(ds) >= 0);
/* Add the dataspace message to the object header */
- if(H5O_msg_append_oh(f, dxpl_id, oh, H5O_SDSPACE_ID, 0, 0, &(ds->extent)) < 0)
+ if(H5O_msg_append_oh(f, oh, H5O_SDSPACE_ID, 0, 0, &(ds->extent)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't add simple dataspace message")
done:
@@ -1145,7 +1150,7 @@ done:
*-------------------------------------------------------------------------
*/
H5S_t *
-H5S_read(const H5O_loc_t *loc, hid_t dxpl_id)
+H5S_read(const H5O_loc_t *loc)
{
H5S_t *ds = NULL; /* Dataspace to return */
H5S_t *ret_value = NULL; /* Return value */
@@ -1158,7 +1163,7 @@ H5S_read(const H5O_loc_t *loc, hid_t dxpl_id)
if(NULL == (ds = H5FL_CALLOC(H5S_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- if(H5O_msg_read(loc, H5O_SDSPACE_ID, &(ds->extent), dxpl_id) == NULL)
+ if(NULL == H5O_msg_read(loc, H5O_SDSPACE_ID, &(ds->extent)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to load dataspace info from dataset header")
/* Default to entire dataspace being selected */
@@ -1545,7 +1550,7 @@ H5Sencode(hid_t obj_id, void *buf, size_t *nalloc)
H5TRACE3("e", "i*x*z", obj_id, buf, nalloc);
/* Check argument and retrieve object */
- if (NULL==(dspace=(H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE)))
+ if (NULL == (dspace = (H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
if(H5S_encode(dspace, (unsigned char **)&buf, nalloc)<0)
@@ -1724,8 +1729,8 @@ H5S_decode(const unsigned char **p)
/* Decode the extent part of dataspace */
/* (pass mostly bogus file pointer and bogus DXPL) */
- if((extent = (H5S_extent_t *)H5O_msg_decode(f, H5P_DEFAULT, NULL, H5O_SDSPACE_ID, pp))==NULL)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode object")
+ if(NULL == (extent = (H5S_extent_t *)H5O_msg_decode(f, NULL, H5O_SDSPACE_ID, extent_size, pp)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode object")
pp += extent_size;
/* Copy the extent into dataspace structure */
@@ -2168,93 +2173,40 @@ H5S_extent_nelem(const H5S_extent_t *ext)
/*-------------------------------------------------------------------------
- * Function: H5S_set_latest_version
+ * Function: H5S_set_version
*
- * Purpose: Set the encoding for a dataspace to the latest version.
+ * Purpose: Set the version to encode a dataspace with.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
- * Tuesday, July 24, 2007
+ * Programmer: Vailin Choi; December 2017
*
*-------------------------------------------------------------------------
*/
herr_t
-H5S_set_latest_version(H5S_t *ds)
+H5S_set_version(H5F_t *f, H5S_t *ds)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Sanity check */
- HDassert(ds);
-
- /* Set encoding of extent to latest version */
- ds->extent.version = H5O_SDSPACE_VERSION_LATEST;
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S_set_latest_version() */
-
-#ifndef H5_NO_DEPRECATED_SYMBOLS
-
-/*-------------------------------------------------------------------------
- * Function: H5S_extend
- *
- * Purpose: Extend the dimensions of a dataspace.
- *
- * Return: Success: Number of dimensions whose size increased.
- *
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * Friday, January 30, 1998
- *
- *-------------------------------------------------------------------------
- */
-int
-H5S_extend(H5S_t *space, const hsize_t *size)
-{
- unsigned u;
- int ret_value = 0;
+ unsigned version; /* Message version */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
- /* Check args */
- HDassert(space && H5S_SIMPLE == H5S_GET_EXTENT_TYPE(space));
- HDassert(size);
-
- /* Check through all the dimensions to see if modifying the dataspace is allowed */
- for(u = 0; u < space->extent.rank; u++)
- if(space->extent.size[u] < size[u]) {
- if(space->extent.max && H5S_UNLIMITED != space->extent.max[u] &&
- space->extent.max[u] < size[u])
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimension cannot be increased")
- ret_value++;
- } /* end if */
-
- /* Update */
- if(ret_value) {
- hsize_t nelem; /* Number of elements in extent */
-
- /* Change the dataspace size & re-compute the number of elements in the extent */
- for(u = 0, nelem = 1; u < space->extent.rank; u++) {
- if(space->extent.size[u] < size[u])
- space->extent.size[u] = size[u];
+ /* Sanity check */
+ HDassert(f);
+ HDassert(ds);
- nelem *= space->extent.size[u];
- } /* end for */
- space->extent.nelem = nelem;
+ /* Upgrade to the version indicated by the file's low bound if higher */
+ version = MAX(ds->extent.version, H5O_sdspace_ver_bounds[H5F_LOW_BOUND(f)]);
- /* If the selection is 'all', update the number of elements selected */
- if(H5S_GET_SELECT_TYPE(space) == H5S_SEL_ALL)
- if(H5S_select_all(space, FALSE) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
+ /* Version bounds check */
+ if(version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(f)])
+ HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "Dataspace version out of bounds")
- /* Mark the dataspace as no longer shared if it was before */
- if(H5O_msg_reset_share(H5O_SDSPACE_ID, space) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRESET, FAIL, "can't stop sharing dataspace")
- } /* end if */
+ /* Set the message version */
+ ds->extent.version = version;
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_extend() */
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+} /* end H5S_set_version() */