diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2007-04-03 20:44:35 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2007-04-03 20:44:35 (GMT) |
commit | 5251117b685c82e18d0c80ceef6888bafa17b5da (patch) | |
tree | d04592b8be4a0e01356e631931ebd8294c6ce2fe /tools | |
parent | 0ee71236ed7c1979e92878d5d7eb4b885b374c39 (diff) | |
download | hdf5-5251117b685c82e18d0c80ceef6888bafa17b5da.zip hdf5-5251117b685c82e18d0c80ceef6888bafa17b5da.tar.gz hdf5-5251117b685c82e18d0c80ceef6888bafa17b5da.tar.bz2 |
[svn-r13581]
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
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5repack/h5repack_refs.c | 15 | ||||
-rw-r--r-- | tools/h5repack/h5repacktst.c | 6 | ||||
-rw-r--r-- | tools/testfiles/h5repack_objs.h5 | bin | 19408 -> 19408 bytes |
3 files changed, 9 insertions, 12 deletions
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index bb19e4e..fc1c19e 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -62,7 +62,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,12 +148,7 @@ 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 @@ -162,7 +156,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 @@ -201,7 +195,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; @@ -575,7 +569,8 @@ 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; diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index c0f516e..3f911c2 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -2415,11 +2415,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 */ @@ -2542,6 +2542,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 Binary files differindex a2d81d2..16d8862 100644 --- a/tools/testfiles/h5repack_objs.h5 +++ b/tools/testfiles/h5repack_objs.h5 |