diff options
Diffstat (limited to 'src/H5Dio.c')
-rw-r--r-- | src/H5Dio.c | 77 |
1 files changed, 10 insertions, 67 deletions
diff --git a/src/H5Dio.c b/src/H5Dio.c index 03400cf..600f08a 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -69,55 +69,6 @@ H5FL_BLK_DEFINE(type_conv); H5FL_DEFINE(H5D_chunk_map_t); /*------------------------------------------------------------------------- - * Function: H5D__get_offset_copy - * - * Purpose: Copies an offset buffer and performs bounds checks on the - * values. - * - * This helper function ensures that the offset buffer given - * by the user is suitable for use with the rest of the library. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_copy) -{ - unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(dset); - HDassert(offset); - HDassert(offset_copy); - - /* The library's chunking code requires the offset to terminate with a zero. - * So transfer the offset array to an internal offset array that we - * can properly terminate (handled via the calloc call). - */ - - HDmemset(offset_copy, 0, H5O_LAYOUT_NDIMS * sizeof(hsize_t)); - - for (u = 0; u < dset->shared->ndims; u++) { - /* Make sure the offset doesn't exceed the dataset's dimensions */ - if (offset[u] > dset->shared->curr_dims[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset") - - /* Make sure the offset fall right on a chunk's boundary */ - if (offset[u] % dset->shared->layout.u.chunk.dim[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary") - - offset_copy[u] = offset[u]; - } - -done: - FUNC_LEAVE_NOAPI(ret_value) - -} /* end H5D__get_offset_copy() */ - -/*------------------------------------------------------------------------- * Function: H5D__read * * Purpose: Reads (part of) a DATASET into application memory BUF. See @@ -161,12 +112,8 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t /* check args */ HDassert(dataset && dataset->oloc.file); - - if (!file_space) - file_space = dataset->shared->space; - if (!mem_space) - mem_space = file_space; - nelmts = H5S_GET_SELECT_NPOINTS(mem_space); + HDassert(file_space); + HDassert(mem_space); /* Set up datatype info for operation */ if (H5D__typeinfo_init(dataset, mem_type_id, FALSE, &type_info) < 0) @@ -189,11 +136,12 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t #endif /*H5_HAVE_PARALLEL*/ /* Make certain that the number of elements in each selection is the same */ + nelmts = H5S_GET_SELECT_NPOINTS(mem_space); if (nelmts != H5S_GET_SELECT_NPOINTS(file_space)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected") - /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ + /* Check for a NULL buffer */ if (NULL == buf) { /* Check for any elements selected (which is invalid) */ if (nelmts > 0) @@ -225,7 +173,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t * Note that in general, this requires us to touch up the memory buffer as * well. */ - if (TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && + if (nelmts > 0 && TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ /* to the beginning of the projected mem space. */ @@ -377,6 +325,8 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_ /* check args */ HDassert(dataset && dataset->oloc.file); + HDassert(file_space); + HDassert(mem_space); /* All filters in the DCPL must have encoding enabled. */ if (!dataset->shared->checked_filters) { @@ -418,20 +368,13 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_ } /* end else */ #endif /*H5_HAVE_PARALLEL*/ - /* Initialize dataspace information */ - if (!file_space) - file_space = dataset->shared->space; - if (!mem_space) - mem_space = file_space; - - nelmts = H5S_GET_SELECT_NPOINTS(mem_space); - /* Make certain that the number of elements in each selection is the same */ + nelmts = H5S_GET_SELECT_NPOINTS(mem_space); if (nelmts != H5S_GET_SELECT_NPOINTS(file_space)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected") - /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ + /* Check for a NULL buffer */ if (NULL == buf) { /* Check for any elements selected (which is invalid) */ if (nelmts > 0) @@ -463,7 +406,7 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_ * Note that in general, this requires us to touch up the memory buffer * as well. */ - if (TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && + if (nelmts > 0 && TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ /* to the beginning of the projected mem space. */ |