summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2007-04-03 20:44:52 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2007-04-03 20:44:52 (GMT)
commitea63d5fb19e8b260178e6f76e8ed0504ded148a3 (patch)
tree893a048c8ebb693e3d3fd1f2d8ece524629ac494
parent0fb88ded47762bcafdd4317a3cd48f4c706a011c (diff)
downloadhdf5-ea63d5fb19e8b260178e6f76e8ed0504ded148a3.zip
hdf5-ea63d5fb19e8b260178e6f76e8ed0504ded148a3.tar.gz
hdf5-ea63d5fb19e8b260178e6f76e8ed0504ded148a3.tar.bz2
[svn-r13582]
Bug fix Substitute a malloc call for a calloc call while allocating a reference buffer Add a test for an empty reference case Tested linux
-rw-r--r--tools/h5repack/h5repack_refs.c21
-rw-r--r--tools/h5repack/h5repacktst.c8
-rw-r--r--tools/testfiles/h5repack_objs.h5bin19581 -> 19589 bytes
3 files changed, 13 insertions, 16 deletions
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index f5e74c2..3b272c8 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -63,7 +63,6 @@ int do_copy_refobjs(hid_t fidin,
hsize_t nelmts; /* number of elements in dataset */
int rank; /* rank of dataset */
hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
- int next; /* external files */
unsigned int i, j;
int k;
@@ -149,13 +148,6 @@ int do_copy_refobjs(hid_t fidin,
if ((msize=H5Tget_size(mtype_id))==0)
goto error;
-
-/*-------------------------------------------------------------------------
- * check for external files
- *-------------------------------------------------------------------------
- */
- if ((next=H5Pget_external_count (dcpl_id))<0)
- goto error;
/*-------------------------------------------------------------------------
* check if the dataset creation property list has filters that
* are not registered in the current configuration
@@ -163,7 +155,7 @@ int do_copy_refobjs(hid_t fidin,
* 2) the internal filters might be turned off
*-------------------------------------------------------------------------
*/
- if (next==0 && h5tools_canreadf((NULL),dcpl_id)==1)
+ if (h5tools_canreadf((NULL),dcpl_id)==1)
{
/*-------------------------------------------------------------------------
* test for a valid output dataset
@@ -202,7 +194,7 @@ int do_copy_refobjs(hid_t fidin,
if ((obj_type = H5Rget_obj_type(dset_in,H5R_OBJECT,buf))<0)
goto error;
- refbuf=HDmalloc((unsigned)nelmts*msize);
+ refbuf=HDcalloc((unsigned)nelmts,msize);
if ( refbuf==NULL){
printf( "cannot allocate memory\n" );
goto error;
@@ -544,6 +536,7 @@ static int copy_refs_attr(hid_t loc_in,
if ((msize=H5Tget_size(mtype_id))==0)
goto error;
+
/*-------------------------------------------------------------------------
* object references are a special case
* we cannot just copy the buffers, but instead we recreate the reference
@@ -575,7 +568,7 @@ static int copy_refs_attr(hid_t loc_in,
if ((obj_type = H5Rget_obj_type(attr_id,H5R_OBJECT,buf))<0)
goto error;
- refbuf=HDmalloc((unsigned)nelmts*msize);
+ refbuf=HDcalloc((unsigned)nelmts,msize);
if ( refbuf==NULL){
printf( "cannot allocate memory\n" );
goto error;
@@ -607,14 +600,15 @@ static int copy_refs_attr(hid_t loc_in,
if ((attr_out=H5Acreate(loc_out,name,ftype_id,space_id,H5P_DEFAULT))<0)
goto error;
- if (nelmts) {
+ if (nelmts)
+ {
if(H5Awrite(attr_out,mtype_id,refbuf)<0)
goto error;
}
-
if (H5Aclose(attr_out)<0)
goto error;
+
if (refbuf)
free(refbuf);
if (buf)
@@ -824,4 +818,3 @@ static const char* MapIdToName(hid_t refobj_id,
}
-
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index 19b4103..81c0e3c 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -168,6 +168,7 @@ int main (void)
* file with fill values
*-------------------------------------------------------------------------
*/
+
TESTING(" copy of datasets (fill values)");
if (h5repack_init (&pack_options, 0)<0)
GOERROR;
@@ -183,6 +184,7 @@ int main (void)
GOERROR;
PASSED();
+
/*-------------------------------------------------------------------------
* file with all kinds of dataset datatypes
*-------------------------------------------------------------------------
@@ -2787,11 +2789,11 @@ void write_dset_in(hid_t loc_id,
/* create 1D attributes with dimension [2], 2 elements */
hsize_t dims[1]={2};
- hsize_t dims1r[1]={1};
+ hsize_t dims1r[1]={2};
char buf1[2][2]= {"ab","de"}; /* string */
char buf2[2]= {1,2}; /* bitfield, opaque */
s_t buf3[2]= {{1,2},{3,4}}; /* compound */
- hobj_ref_t buf4[1]; /* reference */
+ hobj_ref_t buf4[2]; /* reference */
e_t buf45[2]= {RED,GREEN}; /* enum */
hvl_t buf5[2]; /* vlen */
hsize_t dimarray[1]={3}; /* array dimension */
@@ -2914,6 +2916,8 @@ void write_dset_in(hid_t loc_id,
*-------------------------------------------------------------------------
*/
/* object references ( H5R_OBJECT ) */
+ buf4[0]=0;
+ buf4[1]=0;
if (dset_name)
{
status=H5Rcreate(&buf4[0],file_id,dset_name,H5R_OBJECT,-1);
diff --git a/tools/testfiles/h5repack_objs.h5 b/tools/testfiles/h5repack_objs.h5
index edd3a5c..199adc5 100644
--- a/tools/testfiles/h5repack_objs.h5
+++ b/tools/testfiles/h5repack_objs.h5
Binary files differ