summaryrefslogtreecommitdiffstats
path: root/src/H5Dcontig.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-05-05 15:05:17 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-05-05 15:05:17 (GMT)
commit548eec307006ebd01294fad2886421f07c3c92c8 (patch)
treef12a7a425e7c90e8895a205491fd8a85d21d5e90 /src/H5Dcontig.c
parent4ffc0b6acb36064e91a1afeb6eceee704e5af7f2 (diff)
downloadhdf5-548eec307006ebd01294fad2886421f07c3c92c8.zip
hdf5-548eec307006ebd01294fad2886421f07c3c92c8.tar.gz
hdf5-548eec307006ebd01294fad2886421f07c3c92c8.tar.bz2
[svn-r16920] Description:
Merge these trunk revisions which occurred during the 1.8.3 release code freeze back to the 1.8 branch: From Quincey: 16845 16847 16849 16851 16858 16869 16897 From Ray: 16859 16880 From Allen: 16863 Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.6 (amazon) in debug mode Mac OS X/32 10.5.6 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5Dcontig.c')
-rw-r--r--src/H5Dcontig.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index 112eea5..1275ee1 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -61,7 +61,7 @@
/********************/
/* Layout operation callbacks */
-static herr_t H5D_contig_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset,
+static herr_t H5D_contig_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset,
const H5P_genplist_t *dc_plist);
static hbool_t H5D_contig_is_space_alloc(const H5O_layout_t *layout);
static herr_t H5D_contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
@@ -79,7 +79,7 @@ static herr_t H5D_contig_write_one(H5D_io_info_t *io_info, hsize_t offset,
/* Contiguous storage layout I/O ops */
const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = {{
- H5D_contig_new,
+ H5D_contig_construct,
H5D_contig_is_space_alloc,
H5D_contig_io_init,
H5D_contig_read,
@@ -360,7 +360,7 @@ H5D_contig_get_addr(const H5D_t *dset)
/*-------------------------------------------------------------------------
- * Function: H5D_contig_new
+ * Function: H5D_contig_construct
*
* Purpose: Constructs new contiguous layout information for dataset
*
@@ -373,17 +373,20 @@ H5D_contig_get_addr(const H5D_t *dset)
*/
/* ARGSUSED */
static herr_t
-H5D_contig_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset,
+H5D_contig_construct(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset,
const H5P_genplist_t UNUSED *dc_plist)
{
- hssize_t tmp_size; /* Temporary holder for raw data size */
+ hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
+ hsize_t nelmts; /* Number of elements in dataspace */
+ size_t dt_size; /* Size of datatype */
+ hsize_t tmp_size; /* Temporary holder for raw data size */
hsize_t dim[H5O_LAYOUT_NDIMS]; /* Current size of data in elements */
hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */
int ndims; /* Rank of dataspace */
int i; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5D_contig_new)
+ FUNC_ENTER_NOAPI_NOINIT(H5D_contig_construct)
/* Sanity checks */
HDassert(f);
@@ -402,16 +405,31 @@ H5D_contig_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset
if(max_dim[i] > dim[i])
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "extendible contiguous non-external dataset")
- /* Compute the total size of dataset */
- tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * H5T_get_size(dset->shared->type);
- H5_ASSIGN_OVERFLOW(dset->shared->layout.u.contig.size, tmp_size, hssize_t, hsize_t);
+ /* Retrieve the number of elements in the dataspace */
+ if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace")
+ nelmts = (hsize_t)snelmts;
+
+ /* Get the datatype's size */
+ if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype")
+
+ /* Compute the size of the dataset's contiguous storage */
+ tmp_size = nelmts * dt_size;
+
+ /* Check for overflow during multiplication */
+ if(nelmts != (tmp_size / dt_size))
+ HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed")
+
+ /* Assign the dataset's contiguous storage size */
+ dset->shared->layout.u.contig.size = tmp_size;
/* Get the sieve buffer size for this dataset */
dset->shared->cache.contig.sieve_buf_size = H5F_SIEVE_BUF_SIZE(f);
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_contig_new() */
+} /* end H5D_contig_construct() */
/*-------------------------------------------------------------------------