summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repack_copy.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-01-28 16:06:09 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-01-28 16:06:09 (GMT)
commit500292582fa8bde8c0520c04fe597c39c98f2bd9 (patch)
tree80a1245a816600b665598f52dfeac1e0f1b9e5c1 /tools/h5repack/h5repack_copy.c
parent5f16e07bbfd4d91d8a3892cb5a28fd2ad3ffdf96 (diff)
downloadhdf5-500292582fa8bde8c0520c04fe597c39c98f2bd9.zip
hdf5-500292582fa8bde8c0520c04fe597c39c98f2bd9.tar.gz
hdf5-500292582fa8bde8c0520c04fe597c39c98f2bd9.tar.bz2
[svn-r8120] Purpose:
bug fix Description: avoid reading and writing data when one of the dimensions is 0 Solution: Platforms tested: linux solaris AIX Misc. update:
Diffstat (limited to 'tools/h5repack/h5repack_copy.c')
-rw-r--r--tools/h5repack/h5repack_copy.c83
1 files changed, 39 insertions, 44 deletions
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index c14d1f0..bdde91c 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -239,10 +239,8 @@ int do_copy_objects(hid_t fidin,
* in a second traversal of the output file
*-------------------------------------------------------------------------
*/
-
- if ( H5Tget_class(mtype_id) != H5T_REFERENCE )
+ if ( (H5T_REFERENCE!=H5Tget_class(mtype_id)))
{
-
/* the information about the object to be filtered/"layouted" */
pack_info_t obj;
init_packobject(&obj);
@@ -254,64 +252,64 @@ int do_copy_objects(hid_t fidin,
* read to memory
*-------------------------------------------------------------------------
*/
-
- buf=(void *) HDmalloc((unsigned)(nelmts*msize));
- if ( buf==NULL){
- printf( "cannot read into memory\n" );
- goto error;
- }
- if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- goto error;
-
- /*-------------------------------------------------------------------------
- * apply the layout; check first if the object is to be modified.
- * if the layout could not be applied, continue
- *-------------------------------------------------------------------------
- */
- if (layout_this(dcpl_id,travt->objs[i].name,options,&obj))
+ if (nelmts)
{
- if (apply_layout(dcpl_id,&obj)<0)
- continue;
- }
-
+ buf=(void *) HDmalloc((unsigned)(nelmts*msize));
+ if ( buf==NULL){
+ printf( "cannot read into memory\n" );
+ goto error;
+ }
+ if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * apply the layout; check first if the object is to be modified.
+ * if the layout could not be applied, continue
+ *-------------------------------------------------------------------------
+ */
+ if (layout_this(dcpl_id,travt->objs[i].name,options,&obj))
+ {
+ if (apply_layout(dcpl_id,&obj)<0)
+ continue;
+ }
/*-------------------------------------------------------------------------
* apply the filter; check first if the object is to be filtered.
* if the filter could not be applied, continue
*-------------------------------------------------------------------------
*/
- if (filter_this(travt->objs[i].name,options,&obj))
- {
- if (rank)
+ if (filter_this(travt->objs[i].name,options,&obj))
{
- /* filters require CHUNK layout; if we do not have one define a default */
- if (obj.chunk.rank<=0)
+ if (rank)
{
- obj.chunk.rank=rank;
- for (j=0; j<rank; j++)
- obj.chunk.chunk_lengths[j] = dims[j];
+ /* filters require CHUNK layout; if we do not have one define a default */
+ if (obj.chunk.rank<=0)
+ {
+ obj.chunk.rank=rank;
+ for (j=0; j<rank; j++)
+ obj.chunk.chunk_lengths[j] = dims[j];
+ }
+ if (apply_filters(dcpl_id,H5Tget_size(mtype_id),options,&obj)<0)
+ continue;
}
- if (apply_filters(dcpl_id,H5Tget_size(mtype_id),options,&obj)<0)
- continue;
- }
- else
- {
- if (options->verbose)
- printf("Warning: Filter could not be applied to <%s>\n",
+ else
+ {
+ if (options->verbose)
+ printf("Warning: Filter could not be applied to <%s>\n",
travt->objs[i].name);
+ }
}
- }
+ }/*nelmts*/
/*-------------------------------------------------------------------------
* create/write dataset/close
*-------------------------------------------------------------------------
*/
- if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,ftype_id,space_id,dcpl_id))<0)
+ if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_id))<0)
goto error;
- if (dsize_in) {
+ if (dsize_in && nelmts) {
if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
goto error;
}
-
/*-------------------------------------------------------------------------
* copy attrs
*-------------------------------------------------------------------------
@@ -332,16 +330,13 @@ int do_copy_objects(hid_t fidin,
if (buf)
free(buf);
-
}/*H5T_STD_REF_OBJ*/
-
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
-
if (H5Tclose(ftype_id)<0)
goto error;
if (H5Tclose(mtype_id)<0)