summaryrefslogtreecommitdiffstats
path: root/src/H5Dint.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/H5Dint.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/H5Dint.c')
-rw-r--r--src/H5Dint.c48
1 files changed, 36 insertions, 12 deletions
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 0e71ef8..00bc347 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -457,8 +457,9 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id)
{
H5S_t *space; /* Dataset's dataspace */
hsize_t space_allocated; /* The number of bytes allocated for chunks */
- hssize_t total_elem; /* The total number of elements in dataspace */
- size_t type_size; /* The size of the datatype for the dataset */
+ 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 full_size; /* The number of bytes in the dataset when fully populated */
herr_t ret_value = SUCCEED;
@@ -471,16 +472,20 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id)
HDassert(space);
/* Get the total number of elements in dataset's dataspace */
- if((total_elem=H5S_GET_EXTENT_NPOINTS(space)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get # of dataspace elements")
+ if((snelmts = H5S_GET_EXTENT_NPOINTS(space)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace")
+ nelmts = (hsize_t)snelmts;
/* Get the size of the dataset's datatype */
- if((type_size = H5T_get_size(dset->shared->type)) == 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get size of datatype")
+ 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 maximum size of the dataset in bytes */
- H5_CHECK_OVERFLOW(total_elem,hssize_t,hsize_t);
- full_size=((hsize_t)total_elem)*type_size;
+ full_size = nelmts * dt_size;
+
+ /* Check for overflow during multiplication */
+ if(nelmts != (full_size / dt_size))
+ HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed")
/* Difficult to error check, since the error value is 0 and 0 is a valid value... :-/ */
space_allocated = H5D_get_storage_size(dset, dxpl_id);
@@ -1132,7 +1137,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id,
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize I/O operations")
/* Create the layout information for the new dataset */
- if((new_dset->shared->layout.ops->new)(file, dapl_id, dxpl_id, new_dset, dc_plist) < 0)
+ if((new_dset->shared->layout.ops->construct)(file, dapl_id, dxpl_id, new_dset, dc_plist) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize layout information")
/* Indicate that the layout information was initialized */
@@ -1392,10 +1397,29 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id)
* truncate the dimension sizes to 32-bits of information. - QAK 5/26/04
*/
if(dataset->shared->layout.version < 3) {
- 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 */
+
+ /* Retrieve the number of elements in the dataspace */
+ if((snelmts = H5S_GET_EXTENT_NPOINTS(dataset->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(dataset->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")
- tmp_size = H5S_GET_EXTENT_NPOINTS(dataset->shared->space) * H5T_get_size(dataset->shared->type);
- H5_ASSIGN_OVERFLOW(dataset->shared->layout.u.contig.size, tmp_size, hssize_t, hsize_t);
+ /* Assign the dataset's contiguous storage size */
+ dataset->shared->layout.u.contig.size = tmp_size;
} /* end if */
/* Get the sieve buffer size for this dataset */