summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-07-20 17:11:38 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-07-20 17:11:38 (GMT)
commitf75ed67d2b624fa4b72207eba13c9f0a34605a47 (patch)
treef068dbef01150f075faffa6faf2de290d9c7e8b3
parent7547be91e5d7545dae1db0ee78e4f20661e4bddb (diff)
downloadhdf5-f75ed67d2b624fa4b72207eba13c9f0a34605a47.zip
hdf5-f75ed67d2b624fa4b72207eba13c9f0a34605a47.tar.gz
hdf5-f75ed67d2b624fa4b72207eba13c9f0a34605a47.tar.bz2
[svn-r8902] Purpose:
Bug fix Description: Allow buffer parameter to H5Dread & H5Dwrite to be NULL if there are no elements to transfer. Platforms tested: FreeBSD 4.10 (sleipnir) w/parallel Too minor to require h5committest
-rw-r--r--release_docs/RELEASE.txt3
-rw-r--r--src/H5Dio.c9
-rw-r--r--test/tselect.c271
3 files changed, 135 insertions, 148 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 4b4ee3a..f0c6f7e 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -82,6 +82,9 @@ Bug Fixes since HDF5-1.6.2 release
Library
-------
+ - Allow NULL pointer for buffer parameter to H5Dread & H5Dwrite
+ when not writing data ("none" selection or hyperslab or point
+ selection with no elements defined). QAK - 2004/07/20
- Calling H5Gcreate() on "/" or "." throws an error instead of
failing quietly. JML - 2004/07/19
- Fixed bug where setting file address size to be very small could
diff --git a/src/H5Dio.c b/src/H5Dio.c
index a684329..e224fea 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -481,7 +481,7 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
else
if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
- if (!buf)
+ if (!buf && H5S_GET_SELECT_NPOINTS(file_space)!=0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer")
/* read raw data */
@@ -569,7 +569,7 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
else
if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
- if (!buf)
+ if (!buf && H5S_GET_SELECT_NPOINTS(file_space)!=0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer")
/* write raw data */
@@ -650,7 +650,6 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
/* check args */
assert(dataset && dataset->ent.file);
- assert(buf);
/* Get memory datatype */
if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE)))
@@ -821,8 +820,7 @@ done:
* Removed the must_convert parameter and move preconditions to
* H5S_<foo>_opt_possible() routine
*
- * Nat Furrer and James Laird
- * June 17, 2004
+ * Nat Furrer and James Laird, 2004/6/7
* Added check for filter encode capability
*-------------------------------------------------------------------------
*/
@@ -848,7 +846,6 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
/* check args */
assert(dataset && dataset->ent.file);
- assert(buf);
/* Get the memory datatype */
if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE)))
diff --git a/test/tselect.c b/test/tselect.c
index bea1e89..c74b90a 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -12,8 +12,6 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/* $Id$ */
-
/***********************************************************
*
* Test program: tselect
@@ -255,6 +253,12 @@ test_select_hyper(hid_t xfer_plist)
ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,wbuf);
CHECK(ret, FAIL, "H5Dwrite");
+ /* Exercise check for NULL buffer and valid selection */
+ H5E_BEGIN_TRY {
+ ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,NULL);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Dwrite");
+
/* Close memory dataspace */
ret = H5Sclose(sid2);
CHECK(ret, FAIL, "H5Sclose");
@@ -275,6 +279,12 @@ test_select_hyper(hid_t xfer_plist)
ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,rbuf);
CHECK(ret, FAIL, "H5Dread");
+ /* Exercise check for NULL buffer and valid selection */
+ H5E_BEGIN_TRY {
+ ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,NULL);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Dread");
+
/* Check that the values match with a dataset iterator */
tbuf=wbuf+(15*SPACE2_DIM2);
ret = H5Diterate(rbuf,H5T_NATIVE_UCHAR,sid2,test_select_hyper_iter1,&tbuf);
@@ -860,8 +870,8 @@ test_select_combo(void)
MESSAGE(5, ("Testing Combination of Hyperslab & Element Selection Functions\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
- rbuf=calloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2);
+ wbuf=HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=HDcalloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
@@ -933,9 +943,8 @@ test_select_combo(void)
for(i=0; i<POINT1_NPOINTS; i++) {
tbuf=wbuf+i;
tbuf2=rbuf+(i*SPACE3_DIM2);
- if(*tbuf!=*tbuf2) {
+ if(*tbuf!=*tbuf2)
TestErrPrintf("element values don't match!, i=%d\n",i);
- } /* end if */
} /* end for */
/* Close memory dataspace */
@@ -955,8 +964,8 @@ test_select_combo(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_combo() */
int
@@ -1025,8 +1034,8 @@ test_select_hyper_stride(hid_t xfer_plist)
MESSAGE(5, ("Testing Hyperslabs with Strides Functionality\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2);
- rbuf=calloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2);
+ wbuf=HDmalloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=HDcalloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
@@ -1119,8 +1128,8 @@ test_select_hyper_stride(hid_t xfer_plist)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_hyper_stride() */
/****************************************************************
@@ -1150,8 +1159,8 @@ test_select_hyper_contig(hid_t dset_type, hid_t xfer_plist)
MESSAGE(5, ("Testing Contiguous Hyperslabs Functionality\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2);
- rbuf=calloc(sizeof(uint16_t),SPACE2_DIM1*SPACE2_DIM2);
+ wbuf=HDmalloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=HDcalloc(sizeof(uint16_t),SPACE2_DIM1*SPACE2_DIM2);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
@@ -1248,8 +1257,8 @@ test_select_hyper_contig(hid_t dset_type, hid_t xfer_plist)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_hyper_contig() */
/****************************************************************
@@ -1277,8 +1286,8 @@ test_select_hyper_contig2(hid_t dset_type, hid_t xfer_plist)
MESSAGE(5, ("Testing More Contiguous Hyperslabs Functionality\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint16_t)*SPACE8_DIM1*SPACE8_DIM2*SPACE8_DIM3*SPACE8_DIM4);
- rbuf=calloc(sizeof(uint16_t),SPACE8_DIM1*SPACE8_DIM2*SPACE8_DIM3*SPACE8_DIM4);
+ wbuf=HDmalloc(sizeof(uint16_t)*SPACE8_DIM1*SPACE8_DIM2*SPACE8_DIM3*SPACE8_DIM4);
+ rbuf=HDcalloc(sizeof(uint16_t),SPACE8_DIM1*SPACE8_DIM2*SPACE8_DIM3*SPACE8_DIM4);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE8_DIM1; i++)
@@ -1369,8 +1378,8 @@ test_select_hyper_contig2(hid_t dset_type, hid_t xfer_plist)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_hyper_contig2() */
/****************************************************************
@@ -1401,8 +1410,8 @@ test_select_hyper_contig3(hid_t dset_type, hid_t xfer_plist)
MESSAGE(5, ("Testing Yet More Contiguous Hyperslabs Functionality\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint16_t)*SPACE8_DIM1*SPACE8_DIM2*SPACE8_DIM3*SPACE8_DIM4);
- rbuf=calloc(sizeof(uint16_t),SPACE8_DIM1*SPACE8_DIM2*SPACE8_DIM3*SPACE8_DIM4);
+ wbuf=HDmalloc(sizeof(uint16_t)*SPACE8_DIM1*SPACE8_DIM2*SPACE8_DIM3*SPACE8_DIM4);
+ rbuf=HDcalloc(sizeof(uint16_t),SPACE8_DIM1*SPACE8_DIM2*SPACE8_DIM3*SPACE8_DIM4);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE8_DIM4; i++)
@@ -1504,8 +1513,8 @@ test_select_hyper_contig3(hid_t dset_type, hid_t xfer_plist)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_hyper_contig3() */
/****************************************************************
@@ -1538,9 +1547,9 @@ test_select_hyper_copy(void)
MESSAGE(5, ("Testing Hyperslabs with Strides Functionality\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2);
- rbuf=calloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2);
- rbuf2=calloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2);
+ wbuf=HDmalloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=HDcalloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2);
+ rbuf2=HDcalloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
@@ -1661,9 +1670,9 @@ test_select_hyper_copy(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
- free(rbuf2);
+ HDfree(wbuf);
+ HDfree(rbuf);
+ HDfree(rbuf2);
} /* test_select_hyper_copy() */
/****************************************************************
@@ -1695,9 +1704,9 @@ test_select_point_copy(void)
MESSAGE(5, ("Testing Hyperslabs with Strides Functionality\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2);
- rbuf=calloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2);
- rbuf2=calloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2);
+ wbuf=HDmalloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=HDcalloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2);
+ rbuf2=HDcalloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
@@ -1801,9 +1810,8 @@ test_select_point_copy(void)
CHECK(ret, FAIL, "H5Dread");
/* Compare data read with data written out */
- if(HDmemcmp(rbuf,rbuf2,sizeof(uint16_t)*SPACE3_DIM1*SPACE3_DIM2)) {
+ if(HDmemcmp(rbuf,rbuf2,sizeof(uint16_t)*SPACE3_DIM1*SPACE3_DIM2))
TestErrPrintf("point values don't match!\n");
- } /* end if */
/* Close memory dataspace */
ret = H5Sclose(sid2);
@@ -1830,9 +1838,9 @@ test_select_point_copy(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
- free(rbuf2);
+ HDfree(wbuf);
+ HDfree(rbuf);
+ HDfree(rbuf2);
} /* test_select_point_copy() */
/****************************************************************
@@ -1869,8 +1877,8 @@ test_select_hyper_offset(void)
MESSAGE(5, ("Testing Hyperslab Selection Functions with Offsets\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
- rbuf=calloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2);
+ wbuf=HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=HDcalloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
@@ -1969,9 +1977,8 @@ test_select_hyper_offset(void)
tbuf=wbuf+((i+5)*SPACE2_DIM2);
tbuf2=rbuf+(i*SPACE3_DIM2);
for(j=0; j<SPACE3_DIM2; j++, tbuf++, tbuf2++) {
- if(*tbuf!=*tbuf2) {
+ if(*tbuf!=*tbuf2)
TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%u, *tbuf2=%u\n",__LINE__,i,j,(unsigned)*tbuf,(unsigned)*tbuf2);
- } /* end if */
} /* end for */
} /* end for */
@@ -1992,8 +1999,8 @@ test_select_hyper_offset(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_hyper_offset() */
/****************************************************************
@@ -2025,8 +2032,8 @@ test_select_hyper_offset2(void)
MESSAGE(5, ("Testing More Hyperslab Selection Functions with Offsets\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint8_t)*SPACE7_DIM1*SPACE7_DIM2);
- rbuf=calloc(sizeof(uint8_t),SPACE7_DIM1*SPACE7_DIM2);
+ wbuf=HDmalloc(sizeof(uint8_t)*SPACE7_DIM1*SPACE7_DIM2);
+ rbuf=HDcalloc(sizeof(uint8_t),SPACE7_DIM1*SPACE7_DIM2);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
@@ -2087,9 +2094,8 @@ test_select_hyper_offset2(void)
tbuf=wbuf+((i+3)*SPACE7_DIM2);
tbuf2=rbuf+((i+3)*SPACE7_DIM2);
for(j=0; j<SPACE7_DIM2; j++, tbuf++, tbuf2++) {
- if(*tbuf!=*tbuf2) {
+ if(*tbuf!=*tbuf2)
TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%u, *tbuf2=%u\n",__LINE__,i,j,(unsigned)*tbuf,(unsigned)*tbuf2);
- } /* end if */
} /* end for */
} /* end for */
@@ -2110,8 +2116,8 @@ test_select_hyper_offset2(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_hyper_offset2() */
/****************************************************************
@@ -2146,8 +2152,8 @@ test_select_point_offset(void)
MESSAGE(5, ("Testing Element Selection Functions\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
- rbuf=calloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2);
+ wbuf=HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=HDcalloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
@@ -2259,9 +2265,8 @@ test_select_point_offset(void)
for(i=0; i<POINT1_NPOINTS; i++) {
tbuf=wbuf+((coord2[i][0]+offset[0])*SPACE2_DIM2)+coord2[i][1]+offset[1];
tbuf2=rbuf+(coord3[i][0]*SPACE3_DIM2)+coord3[i][1];
- if(*tbuf!=*tbuf2) {
+ if(*tbuf!=*tbuf2)
TestErrPrintf("element values don't match!, i=%d\n",i);
- } /* end if */
} /* end for */
/* Close memory dataspace */
@@ -2281,8 +2286,8 @@ test_select_point_offset(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_point_offset() */
/****************************************************************
@@ -2324,8 +2329,8 @@ test_select_hyper_union(void)
MESSAGE(5, ("Testing Hyperslab Selection Functions with unions of hyperslabs\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
- rbuf=calloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2);
+ wbuf=HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=HDcalloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
@@ -2407,9 +2412,8 @@ test_select_hyper_union(void)
tbuf=wbuf+((i+15)*SPACE2_DIM2);
tbuf2=rbuf+(i*SPACE3_DIM2);
for(j=0; j<SPACE3_DIM2; j++, tbuf++, tbuf2++) {
- if(*tbuf!=*tbuf2) {
+ if(*tbuf!=*tbuf2)
TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2);
- } /* end if */
} /* end for */
} /* end for */
@@ -2501,9 +2505,8 @@ test_select_hyper_union(void)
tbuf=wbuf+((i+15)*SPACE2_DIM2);
tbuf2=rbuf+(i*SPACE3_DIM2);
for(j=0; j<SPACE3_DIM2; j++, tbuf++, tbuf2++) {
- if(*tbuf!=*tbuf2) {
+ if(*tbuf!=*tbuf2)
TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2);
- } /* end if */
} /* end for */
} /* end for */
@@ -2591,9 +2594,8 @@ test_select_hyper_union(void)
tbuf=wbuf+((i+15)*SPACE2_DIM2);
tbuf2=rbuf+(i*SPACE3_DIM2);
for(j=0; j<SPACE3_DIM2; j++, tbuf++, tbuf2++) {
- if(*tbuf!=*tbuf2) {
+ if(*tbuf!=*tbuf2)
TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2);
- } /* end if */
} /* end for */
} /* end for */
@@ -2694,9 +2696,8 @@ test_select_hyper_union(void)
tbuf=wbuf+((i+15)*SPACE2_DIM2);
tbuf2=rbuf+(i*SPACE3_DIM2);
for(j=0; j<SPACE3_DIM2; j++, tbuf++, tbuf2++) {
- if(*tbuf!=*tbuf2) {
+ if(*tbuf!=*tbuf2)
TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2);
- } /* end if */
} /* end for */
} /* end for */
@@ -2779,9 +2780,8 @@ test_select_hyper_union(void)
for(i=0,tbuf2=rbuf; i<SPACE2_DIM1; i++) {
tbuf=wbuf+(i*SPACE2_DIM2)+begin[i];
for(j=0; j<(int)len[i]; j++, tbuf++, tbuf2++) {
- if(*tbuf!=*tbuf2) {
+ if(*tbuf!=*tbuf2)
TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2);
- } /* end if */
} /* end for */
} /* end for */
@@ -2802,8 +2802,8 @@ test_select_hyper_union(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_hyper_union() */
/****************************************************************
@@ -3217,8 +3217,8 @@ test_select_hyper_nota_2d(void)
MESSAGE(5, ("Testing Hyperslab Selection Functions with NOTA of 2-D hyperslabs\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
- rbuf=calloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2);
+ wbuf=HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=HDcalloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
@@ -3284,12 +3284,12 @@ test_select_hyper_nota_2d(void)
if(((i>=10 && i<=14) && (j>=5 && j<=14)) ||
((i>=5 && i<=9) && (j>=10 && j<=14))) {
if(*tbuf!=*tbuf2)
- printf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2);
+ TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2);
tbuf2++;
} /* end if */
else {
if(*tbuf!=0)
- printf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n",__LINE__,i,j,(int)*tbuf);
+ TestErrPrintf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n",__LINE__,i,j,(int)*tbuf);
} /* end else */
} /* end for */
@@ -3310,8 +3310,8 @@ test_select_hyper_nota_2d(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_hyper_nota_2d() */
/****************************************************************
@@ -3374,8 +3374,8 @@ test_select_hyper_union_random_5d(hid_t read_plist)
MESSAGE(5, ("Testing Hyperslab Selection Functions with random unions of 5-D hyperslabs\n"));
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(int)*SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5);
- rbuf=calloc(sizeof(int),SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5);
+ wbuf=HDmalloc(sizeof(int)*SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5);
+ rbuf=HDcalloc(sizeof(int),SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5);
/* Initialize write buffer */
for(i=0, tbuf=wbuf; i<SPACE5_DIM1; i++)
@@ -3522,8 +3522,8 @@ printf("random I/O, after H5Dread()\n");
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
} /* test_select_hyper_union_random_5d() */
/****************************************************************
@@ -3564,8 +3564,8 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist)
MESSAGE(5, ("Testing Hyperslab I/O on Large Chunks\n"));
/* Allocate the transfer buffers */
- data = (short*)malloc(sizeof(short)*X*Y*Z);
- data_out = (short*)calloc(NX*NY*NZ,sizeof(short));
+ data = HDmalloc(sizeof(short)*X*Y*Z);
+ data_out = HDcalloc(NX*NY*NZ,sizeof(short));
/*
* Data buffer initialization.
@@ -3737,9 +3737,8 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist)
for (j = 0; j < X; j++)
for (i = 0; i < Y; i++)
for (k = 0; k < Z; k++,tmpdata++,tmpdata_out++) {
- if(*tmpdata!=*tmpdata_out) {
+ if(*tmpdata!=*tmpdata_out)
TestErrPrintf("Line %d: Error! j=%d, i=%d, k=%d, *tmpdata=%x, *tmpdata_out=%x\n",__LINE__,j,i,k,(unsigned)*tmpdata,(unsigned)*tmpdata_out);
- } /* end if */
} /* end for */
/*
@@ -3753,8 +3752,8 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist)
CHECK(status, FAIL, "H5Sclose");
status=H5Fclose (file);
CHECK(status, FAIL, "H5Fclose");
- free (data);
- free (data_out);
+ HDfree (data);
+ HDfree (data_out);
} /* test_select_hyper_chunk() */
/****************************************************************
@@ -4537,7 +4536,7 @@ test_select_fill_all(void)
MESSAGE(5, ("Testing Filling 'all' Selections\n"));
/* Allocate memory buffer */
- wbuf=malloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf=HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
/* Initialize memory buffer */
for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
@@ -4560,9 +4559,8 @@ test_select_fill_all(void)
/* Verify memory buffer the hard way... */
for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
for(j=0; j<SPACE7_DIM2; j++)
- if(*tbuf!=(unsigned short)fill_value) {
+ if(*tbuf!=(unsigned short)fill_value)
TestErrPrintf("Error! j=%d, i=%d, *tbuf=%x, fill_value=%x\n",j,i,(unsigned)*tbuf,(unsigned)fill_value);
- } /* end if */
/* Set the coordinates of the selection */
for(i=0; i<SPACE7_DIM1; i++)
@@ -4585,7 +4583,7 @@ test_select_fill_all(void)
CHECK(ret, FAIL, "H5Sclose");
/* Free memory buffers */
- free(wbuf);
+ HDfree(wbuf);
} /* test_select_fill_all() */
/****************************************************************
@@ -4613,7 +4611,7 @@ test_select_fill_point(hssize_t *offset)
MESSAGE(5, ("Testing Filling 'point' Selections\n"));
/* Allocate memory buffer */
- wbuf=malloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf=HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
/* Initialize memory buffer */
for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
@@ -4650,15 +4648,13 @@ test_select_fill_point(hssize_t *offset)
for(j=0; j<SPACE7_DIM2; j++, tbuf++) {
for(k=0; k<(int)num_points; k++) {
if(i==(points[k][0]+real_offset[0]) && j==(points[k][1]+real_offset[1])) {
- if(*tbuf!=(unsigned short)fill_value) {
+ if(*tbuf!=(unsigned short)fill_value)
TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, fill_value=%u\n",j,i,(unsigned)*tbuf,(unsigned)fill_value);
- } /* end if */
break;
} /* end if */
} /* end for */
- if(k==(int)num_points && *tbuf!=((unsigned short)(i*SPACE7_DIM2)+j)) {
+ if(k==(int)num_points && *tbuf!=((unsigned short)(i*SPACE7_DIM2)+j))
TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, should be: %u\n",j,i,(unsigned)*tbuf,(unsigned)((i*SPACE7_DIM2)+j));
- } /* end if */
} /* end for */
/* Initialize the iterator structure */
@@ -4681,7 +4677,7 @@ test_select_fill_point(hssize_t *offset)
CHECK(ret, FAIL, "H5Sclose");
/* Free memory buffers */
- free(wbuf);
+ HDfree(wbuf);
} /* test_select_fill_point() */
/****************************************************************
@@ -4711,7 +4707,7 @@ test_select_fill_hyper_simple(hssize_t *offset)
MESSAGE(5, ("Testing Filling Simple 'hyperslab' Selections\n"));
/* Allocate memory buffer */
- wbuf=malloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf=HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
/* Initialize memory buffer */
for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
@@ -4750,14 +4746,12 @@ test_select_fill_hyper_simple(hssize_t *offset)
for(j=0; j<SPACE7_DIM2; j++, tbuf++) {
if((i>=(int)(start[0]+real_offset[0]) && i<(int)(start[0]+count[0]+real_offset[0]))
&& (j>=(int)(start[1]+real_offset[1]) && j<(int)(start[1]+count[1]+real_offset[1]))) {
- if(*tbuf!=(unsigned short)fill_value) {
+ if(*tbuf!=(unsigned short)fill_value)
TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, fill_value=%u\n",j,i,(unsigned)*tbuf,(unsigned)fill_value);
- } /* end if */
} /* end if */
else {
- if(*tbuf!=((unsigned short)(i*SPACE7_DIM2)+j)) {
+ if(*tbuf!=((unsigned short)(i*SPACE7_DIM2)+j))
TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, should be: %u\n",j,i,(unsigned)*tbuf,(unsigned)((i*SPACE7_DIM2)+j));
- } /* end if */
} /* end else */
} /* end for */
@@ -4782,7 +4776,7 @@ test_select_fill_hyper_simple(hssize_t *offset)
CHECK(ret, FAIL, "H5Sclose");
/* Free memory buffers */
- free(wbuf);
+ HDfree(wbuf);
} /* test_select_fill_hyper_simple() */
/****************************************************************
@@ -4819,7 +4813,7 @@ test_select_fill_hyper_regular(hssize_t *offset)
MESSAGE(5, ("Testing Filling Regular 'hyperslab' Selections\n"));
/* Allocate memory buffer */
- wbuf=malloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf=HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
/* Initialize memory buffer */
for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
@@ -4860,15 +4854,13 @@ test_select_fill_hyper_regular(hssize_t *offset)
for(j=0; j<SPACE7_DIM2; j++, tbuf++) {
for(k=0; k<(int)num_points; k++) {
if(i==(points[k][0]+real_offset[0]) && j==(points[k][1]+real_offset[1])) {
- if(*tbuf!=(unsigned short)fill_value) {
+ if(*tbuf!=(unsigned short)fill_value)
TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, fill_value=%u\n",j,i,(unsigned)*tbuf,(unsigned)fill_value);
- } /* end if */
break;
} /* end if */
} /* end for */
- if(k==(int)num_points && *tbuf!=((unsigned short)(i*SPACE7_DIM2)+j)) {
+ if(k==(int)num_points && *tbuf!=((unsigned short)(i*SPACE7_DIM2)+j))
TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, should be: %u\n",j,i,(unsigned)*tbuf,(unsigned)((i*SPACE7_DIM2)+j));
- } /* end if */
} /* end for */
/* Initialize the iterator structure */
@@ -4891,7 +4883,7 @@ test_select_fill_hyper_regular(hssize_t *offset)
CHECK(ret, FAIL, "H5Sclose");
/* Free memory buffers */
- free(wbuf);
+ HDfree(wbuf);
} /* test_select_fill_hyper_regular() */
/****************************************************************
@@ -4939,7 +4931,7 @@ test_select_fill_hyper_irregular(hssize_t *offset)
MESSAGE(5, ("Testing Filling Irregular 'hyperslab' Selections\n"));
/* Allocate memory buffer */
- wbuf=malloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf=HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
/* Initialize memory buffer */
for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
@@ -4984,15 +4976,13 @@ test_select_fill_hyper_irregular(hssize_t *offset)
for(j=0; j<SPACE7_DIM2; j++, tbuf++) {
for(k=0; k<(int)num_points; k++) {
if(i==(points[k][0]+real_offset[0]) && j==(points[k][1]+real_offset[1])) {
- if(*tbuf!=(unsigned short)fill_value) {
+ if(*tbuf!=(unsigned short)fill_value)
TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, fill_value=%u\n",j,i,(unsigned)*tbuf,(unsigned)fill_value);
- } /* end if */
break;
} /* end if */
} /* end for */
- if(k==(int)num_points && *tbuf!=((unsigned short)(i*SPACE7_DIM2)+j)) {
+ if(k==(int)num_points && *tbuf!=((unsigned short)(i*SPACE7_DIM2)+j))
TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, should be: %u\n",j,i,(unsigned)*tbuf,(unsigned)((i*SPACE7_DIM2)+j));
- } /* end if */
} /* end for */
/* Initialize the iterator structure */
@@ -5015,7 +5005,7 @@ test_select_fill_hyper_irregular(hssize_t *offset)
CHECK(ret, FAIL, "H5Sclose");
/* Free memory buffers */
- free(wbuf);
+ HDfree(wbuf);
} /* test_select_fill_hyper_irregular() */
/****************************************************************
@@ -5079,6 +5069,14 @@ test_select_none(void)
ret=H5Dwrite(dataset,H5T_NATIVE_INT,sid2,sid1,H5P_DEFAULT,wbuf);
CHECK(ret, FAIL, "H5Dwrite");
+ /* Write "nothing" to disk (with NULL buffer argument) */
+ ret=H5Dwrite(dataset,H5T_NATIVE_INT,sid2,sid1,H5P_DEFAULT,NULL);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Read "nothing" from disk (with NULL buffer argument) */
+ ret=H5Dread(dataset,H5T_NATIVE_INT,sid2,sid1,H5P_DEFAULT,NULL);
+ CHECK(ret, FAIL, "H5Dread");
+
/* Close memory dataspace */
ret = H5Sclose(sid2);
CHECK(ret, FAIL, "H5Sclose");
@@ -5128,8 +5126,8 @@ test_scalar_select(void)
MESSAGE(5, ("Testing I/O on Selections in Scalar Dataspaces\n"));
/* Allocate write & read buffers */
- wbuf_uint8=malloc(sizeof(uint8_t)*SPACE7_DIM1*SPACE7_DIM2);
- wbuf_ushort=malloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf_uint8=HDmalloc(sizeof(uint8_t)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf_ushort=HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
/* Initialize write buffers */
for(i=0, tbuf_uint8=wbuf_uint8, tbuf_ushort=wbuf_ushort; i<SPACE7_DIM1; i++)
@@ -5168,9 +5166,8 @@ test_scalar_select(void)
CHECK(ret, FAIL, "H5Dread");
/* Check value read back in */
- if(rval_uint8!=*(wbuf_uint8+2)) {
+ if(rval_uint8!=*(wbuf_uint8+2))
TestErrPrintf("Error! rval=%u, should be: *(wbuf+2)=%u\n",(unsigned)rval_uint8,(unsigned)*(wbuf_uint8+2));
- } /* end if */
/* Write single point to disk (with a datatype conversion) */
ret=H5Dwrite(dataset,H5T_NATIVE_USHORT,sid2,sid1,H5P_DEFAULT,wbuf_ushort);
@@ -5181,9 +5178,8 @@ test_scalar_select(void)
CHECK(ret, FAIL, "H5Dread");
/* Check value read back in */
- if(rval_ushort!=*(wbuf_ushort+2)) {
+ if(rval_ushort!=*(wbuf_ushort+2))
TestErrPrintf("Error! rval=%u, should be: *(wbuf+2)=%u\n",(unsigned)rval_ushort,(unsigned)*(wbuf_ushort+2));
- } /* end if */
/* Select one element in memory with a hyperslab selection */
start[0]=4; start[1]=3;
@@ -5200,9 +5196,8 @@ test_scalar_select(void)
CHECK(ret, FAIL, "H5Dread");
/* Check value read back in */
- if(rval_uint8!=*(wbuf_uint8+(SPACE7_DIM2*4)+3)) {
+ if(rval_uint8!=*(wbuf_uint8+(SPACE7_DIM2*4)+3))
TestErrPrintf("Error! rval=%u, should be: *(wbuf+(SPACE7_DIM2*4)+3)=%u\n",(unsigned)rval_uint8,(unsigned)*(wbuf_uint8+(SPACE7_DIM2*4)+3));
- } /* end if */
/* Write single hyperslab element to disk (with a datatype conversion) */
ret=H5Dwrite(dataset,H5T_NATIVE_USHORT,sid2,sid1,H5P_DEFAULT,wbuf_ushort);
@@ -5213,9 +5208,8 @@ test_scalar_select(void)
CHECK(ret, FAIL, "H5Dread");
/* Check value read back in */
- if(rval_ushort!=*(wbuf_ushort+(SPACE7_DIM2*4)+3)) {
+ if(rval_ushort!=*(wbuf_ushort+(SPACE7_DIM2*4)+3))
TestErrPrintf("Error! rval=%u, should be: *(wbuf+(SPACE7_DIM2*4)+3)=%u\n",(unsigned)rval_ushort,(unsigned)*(wbuf_ushort+(SPACE7_DIM2*4)+3));
- } /* end if */
/* Select no elements in memory & file with "none" selections */
ret = H5Sselect_none(sid1);
@@ -5249,8 +5243,8 @@ test_scalar_select(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free memory buffers */
- free(wbuf_uint8);
- free(wbuf_ushort);
+ HDfree(wbuf_uint8);
+ HDfree(wbuf_ushort);
} /* test_scalar_select() */
/****************************************************************
@@ -6188,9 +6182,9 @@ test_select_hyper_chunk_offset(void)
MESSAGE(6, ("Testing hyperslab selections using offsets in chunked datasets\n"));
/* Allocate buffers */
- wbuf= (int*)HDmalloc(sizeof(int)*SPACE10_DIM1);
+ wbuf= HDmalloc(sizeof(int)*SPACE10_DIM1);
CHECK(wbuf, NULL, "HDmalloc");
- rbuf= (int*)HDmalloc(sizeof(int)*SPACE10_DIM1);
+ rbuf= HDmalloc(sizeof(int)*SPACE10_DIM1);
CHECK(rbuf, NULL, "HDmalloc");
/* Initialize the write buffer */
@@ -6280,13 +6274,10 @@ test_select_hyper_chunk_offset(void)
CHECK(ret, FAIL, "H5Soffset_simple");
/* Verify the information read in */
- for(i=0; i<SPACE10_DIM1; i+=SPACE10_CHUNK_SIZE) {
- for(j=0; j<SPACE10_CHUNK_SIZE; j++) {
- if(wbuf[i+j]!=rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j]) {
+ for(i=0; i<SPACE10_DIM1; i+=SPACE10_CHUNK_SIZE)
+ for(j=0; j<SPACE10_CHUNK_SIZE; j++)
+ if(wbuf[i+j]!=rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j])
TestErrPrintf("Line: %d - Error! i=%d, j=%d, rbuf=%d, wbuf=%d\n",__LINE__,i,j,rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j],wbuf[i+j]);
- } /* end if */
- } /* end for */
- } /* end for */
/* Check with 'OR'ed set of hyperslab selections, which makes certain the
* hyperslab spanlist code gets tested. -QAK
@@ -6352,16 +6343,12 @@ test_select_hyper_chunk_offset(void)
CHECK(ret, FAIL, "H5Soffset_simple");
/* Verify the information read in */
- for(i=0; i<SPACE10_DIM1; i+=SPACE10_CHUNK_SIZE) {
- for(j=0; j<SPACE10_CHUNK_SIZE; j++) {
+ for(i=0; i<SPACE10_DIM1; i+=SPACE10_CHUNK_SIZE)
+ for(j=0; j<SPACE10_CHUNK_SIZE; j++)
/* We're not writing out the "middle" of each chunk, so don't check that */
- if(j<(SPACE10_CHUNK_SIZE/3) || j>=((2*SPACE10_CHUNK_SIZE)/3)) {
- if(wbuf[i+j]!=rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j]) {
+ if(j<(SPACE10_CHUNK_SIZE/3) || j>=((2*SPACE10_CHUNK_SIZE)/3))
+ if(wbuf[i+j]!=rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j])
TestErrPrintf("Line: %d - Error! i=%d, j=%d, rbuf=%d, wbuf=%d\n",__LINE__,i,j,rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j],wbuf[i+j]);
- } /* end if */
- } /* end if */
- } /* end for */
- } /* end for */
/* Close the memory dataspace */
ret=H5Sclose (msid);