summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5D.c69
-rw-r--r--src/H5Ddeprec.c6
-rw-r--r--src/H5Dpublic.h16
-rw-r--r--src/H5S.c130
-rw-r--r--src/H5Sprivate.h4
5 files changed, 126 insertions, 99 deletions
diff --git a/src/H5D.c b/src/H5D.c
index a6b9a52..5133651 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -3077,8 +3077,8 @@ done:
/*-------------------------------------------------------------------------
* Function: H5Dset_extent
*
- * Purpose: Modifies the dimensions of a dataset, based on H5Dextend.
- * Can change to a lower dimension.
+ * Purpose: Modifies the dimensions of a dataset.
+ * Can change to a smaller dimension.
*
* Return: Non-negative on success, negative on failure
*
@@ -3130,10 +3130,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id)
H5S_t *space; /* Dataset's dataspace */
int rank; /* Dataspace # of dimensions */
hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */
- hbool_t shrink = FALSE; /* Flag to indicate a dimension has shrank */
- hbool_t expand = FALSE; /* Flag to indicate a dimension has grown */
htri_t changed; /* Whether the dataspace changed size */
- unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5D_set_extent, FAIL)
@@ -3142,40 +3139,44 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id)
HDassert(dset);
HDassert(size);
- /*-------------------------------------------------------------------------
- * Get the data space
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * Get the data space
+ *-------------------------------------------------------------------------
+ */
space = dset->shared->space;
- /*-------------------------------------------------------------------------
- * Check if we are shrinking or expanding any of the dimensions
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * Check if we are shrinking or expanding any of the dimensions
+ *-------------------------------------------------------------------------
+ */
if((rank = H5S_get_simple_extent_dims(space, curr_dims, NULL)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions")
- /* Determine if we are shrinking and/or expanding any dimensions */
- for(u = 0; u < (unsigned)rank; u++) {
- if(size[u] < curr_dims[u])
- shrink = TRUE;
- if(size[u] > curr_dims[u])
- expand = TRUE;
- } /* end for */
-
- /*-------------------------------------------------------------------------
- * Modify the size of the data space
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * Modify the size of the data space
+ *-------------------------------------------------------------------------
+ */
if((changed = H5S_set_extent(space, size)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of data space")
/* Don't bother updating things, unless they've changed */
if(changed) {
- /*-------------------------------------------------------------------------
- * Modify the dataset storage
- *-------------------------------------------------------------------------
- */
+ hbool_t shrink = FALSE; /* Flag to indicate a dimension has shrank */
+ hbool_t expand = FALSE; /* Flag to indicate a dimension has grown */
+ unsigned u; /* Local index variable */
+
+ /* Determine if we are shrinking and/or expanding any dimensions */
+ for(u = 0; u < (unsigned)rank; u++) {
+ if(size[u] < curr_dims[u])
+ shrink = TRUE;
+ if(size[u] > curr_dims[u])
+ expand = TRUE;
+ } /* end for */
+
+ /*-------------------------------------------------------------------------
+ * Modify the dataset storage
+ *-------------------------------------------------------------------------
+ */
/* Save the new dataspace in the file if necessary */
if(H5S_write(&(dset->oloc), space, TRUE, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace")
@@ -3191,11 +3192,11 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset storage")
- /*-------------------------------------------------------------------------
- * Remove chunk information in the case of chunked datasets
- * This removal takes place only in case we are shrinking the dateset
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * Remove chunk information in the case of chunked datasets
+ * This removal takes place only in case we are shrinking the dateset
+ *-------------------------------------------------------------------------
+ */
if(shrink && H5D_CHUNKED == dset->shared->layout.type) {
H5D_io_info_t io_info; /* Dataset I/O info */
H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c
index fcb67e4..3d58557 100644
--- a/src/H5Ddeprec.c
+++ b/src/H5Ddeprec.c
@@ -65,7 +65,9 @@
/* Local Prototypes */
/********************/
+#ifndef H5_NO_DEPRECATED_SYMBOLS
static herr_t H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id);
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*********************/
@@ -256,6 +258,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Dopen() */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
* Function: H5Dextend
@@ -264,6 +267,8 @@ done:
* SIZE. The dimensionality of SIZE is the same as the data
* space of the dataset being changed.
*
+ * Note: Deprecated in favor of H5Dset_extent
+ *
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
@@ -377,4 +382,5 @@ H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_extend() */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h
index 3ddba7c..bbd74a6 100644
--- a/src/H5Dpublic.h
+++ b/src/H5Dpublic.h
@@ -124,8 +124,24 @@ H5_DLL herr_t H5Ddebug(hid_t dset_id);
H5_DLL hid_t H5Dcreate(hid_t file_id, const char *name, hid_t type_id,
hid_t space_id, hid_t plist_id);
H5_DLL hid_t H5Dopen(hid_t file_id, const char *name);
+
+/* Symbols defined for compatibility with previous versions of the HDF5 API.
+ *
+ * Use of these symbols is deprecated.
+ */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+
+/* Macros */
+
+
+/* Typedefs */
+
+
+/* Function prototypes */
H5_DLL herr_t H5Dextend(hid_t dset_id, const hsize_t *size);
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
#ifdef __cplusplus
}
#endif
diff --git a/src/H5S.c b/src/H5S.c
index 45069c1..f990925 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -1499,70 +1499,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5S_extend
- *
- * Purpose: Extend the dimensions of a data space.
- *
- * 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;
-
- FUNC_ENTER_NOAPI(H5S_extend, 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 */
- } /* end for */
-
- /* 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];
-
- nelem *= space->extent.size[u];
- } /* end for */
- space->extent.nelem = nelem;
-
- /* 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")
-
- /* 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 */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_extend() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5Screate_simple
*
* Purpose: Creates a new simple data space object and opens it for
@@ -2355,3 +2291,69 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_set_latest_version() */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+
+/*-------------------------------------------------------------------------
+ * Function: H5S_extend
+ *
+ * Purpose: Extend the dimensions of a data space.
+ *
+ * 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;
+
+ FUNC_ENTER_NOAPI(H5S_extend, 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 */
+ } /* end for */
+
+ /* 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];
+
+ nelem *= space->extent.size[u];
+ } /* end for */
+ space->extent.nelem = nelem;
+
+ /* 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")
+
+ /* 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 */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5S_extend() */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index 69624c3..c6f2ce5 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -208,7 +208,6 @@ H5_DLL herr_t H5S_write(struct H5O_loc_t *loc, const H5S_t *space,
H5_DLL herr_t H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh,
const H5S_t *ds);
H5_DLL H5S_t *H5S_read(const struct H5O_loc_t *loc, hid_t dxpl_id);
-H5_DLL int H5S_extend(H5S_t *space, const hsize_t *size);
H5_DLL int H5S_set_extent(H5S_t *space, const hsize_t *size);
H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size);
H5_DLL H5S_t *H5S_create(H5S_class_t type);
@@ -217,6 +216,9 @@ H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/],
H5_DLL herr_t H5S_set_latest_version(H5S_t *ds);
H5_DLL herr_t H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
int indent, int fwidth);
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+H5_DLL int H5S_extend(H5S_t *space, const hsize_t *size);
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
H5_DLL hsize_t H5S_extent_nelem(const H5S_extent_t *ext);