summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repack_copy.c
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2010-11-18 14:35:57 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2010-11-18 14:35:57 (GMT)
commit5f1db21f84e7a7d7f91c69865eca9c1a04854422 (patch)
treeb6680f3269116b46feaf4ab2ceeed416c9d1623b /tools/h5repack/h5repack_copy.c
parent76c354a610ef2578e33b58f1f641f8bf10553f52 (diff)
downloadhdf5-5f1db21f84e7a7d7f91c69865eca9c1a04854422.zip
hdf5-5f1db21f84e7a7d7f91c69865eca9c1a04854422.tar.gz
hdf5-5f1db21f84e7a7d7f91c69865eca9c1a04854422.tar.bz2
[svn-r19818] Purpose:
Change to skip copying when a dataset is not allocated. Tested: jam (linux32-LE), amani (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE)
Diffstat (limited to 'tools/h5repack/h5repack_copy.c')
-rw-r--r--tools/h5repack/h5repack_copy.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 6c47cfb..7d2c929 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -559,6 +559,7 @@ int do_copy_objects(hid_t fidin,
named_dt_t *named_dt_head=NULL; /* Pointer to the stack of named datatypes copied */
size_t msize; /* size of type */
hsize_t nelmts; /* number of elements in dataset */
+ H5D_space_status_t *space_status; /* determines whether space has been allocated for the dataset */
int rank; /* rank of dataset */
hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
hsize_t dsize_in; /* input dataset size before filter */
@@ -746,6 +747,10 @@ int do_copy_objects(hid_t fidin,
HDmemset(dims, 0, sizeof dims);
if(H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0)
goto error;
+
+ if(H5Dget_space_status(dset_in, &space_status) <0)
+ goto error;
+
nelmts = 1;
for ( j = 0; j < rank; j++)
{
@@ -834,9 +839,11 @@ int do_copy_objects(hid_t fidin,
* read/write
*-------------------------------------------------------------------------
*/
- if (nelmts)
+ if (nelmts>0 && space_status!=H5D_SPACE_STATUS_NOT_ALLOCATED)
{
size_t need = (size_t)(nelmts*msize); /* bytes needed */
+
+ /* have to read the whole dataset if there is only one element in the dataset */
if ( need < H5TOOLS_MALLOCSIZE )
buf = HDmalloc(need);
@@ -847,7 +854,6 @@ int do_copy_objects(hid_t fidin,
if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0)
goto error;
}
-
else /* possibly not enough memory, read/write by hyperslabs */
{
size_t p_type_nbytes = msize; /*size of memory type */
@@ -949,7 +955,7 @@ int do_copy_objects(hid_t fidin,
sm_buf=NULL;
}
} /* hyperslab read */
- }/*nelmts*/
+ } /* if (nelmts>0 && space_status==H5D_SPACE_STATUS_NOT_ALLOCATED) */
/*-------------------------------------------------------------------------
* amount of compression used