diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-09-30 14:27:10 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-09-30 14:27:10 (GMT) |
commit | b2d661b508a7fc7a2592c13bc6bdc175551f075d (patch) | |
tree | 13baeb0d83a7c2a4c6299993c182b1227c2f6114 /test/tvltypes.c | |
parent | 29ab58b58dce556639ea3154e262895773a8a8df (diff) | |
download | hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2 |
Clang-format of source files
Diffstat (limited to 'test/tvltypes.c')
-rw-r--r-- | test/tvltypes.c | 1793 |
1 files changed, 915 insertions, 878 deletions
diff --git a/test/tvltypes.c b/test/tvltypes.c index e8c69b4..50cfbd7 100644 --- a/test/tvltypes.c +++ b/test/tvltypes.c @@ -12,37 +12,37 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: tvltypes -* -* Test the Variable-Length Datatype functionality -* -*************************************************************/ + * + * Test program: tvltypes + * + * Test the Variable-Length Datatype functionality + * + *************************************************************/ #include "testhdf5.h" #include "H5Dprivate.h" -#define FILENAME "tvltypes.h5" +#define FILENAME "tvltypes.h5" /* 1-D dataset with fixed dimensions */ -#define SPACE1_RANK 1 -#define SPACE1_DIM1 4 +#define SPACE1_RANK 1 +#define SPACE1_DIM1 4 /* 1-D dataset with fixed dimensions */ -#define SPACE3_RANK 1 -#define SPACE3_DIM1 128 -#define L1_INCM 16 -#define L2_INCM 8 -#define L3_INCM 3 +#define SPACE3_RANK 1 +#define SPACE3_DIM1 128 +#define L1_INCM 16 +#define L2_INCM 8 +#define L3_INCM 3 /* 1-D dataset with fixed dimensions */ -#define SPACE4_RANK 1 -#define SPACE4_DIM_SMALL 128 -#define SPACE4_DIM_LARGE (H5D_TEMP_BUF_SIZE / 64) +#define SPACE4_RANK 1 +#define SPACE4_DIM_SMALL 128 +#define SPACE4_DIM_LARGE (H5D_TEMP_BUF_SIZE / 64) void *test_vltypes_alloc_custom(size_t size, void *info); -void test_vltypes_free_custom(void *mem, void *info); +void test_vltypes_free_custom(void *mem, void *info); /**************************************************************** ** @@ -52,22 +52,23 @@ void test_vltypes_free_custom(void *mem, void *info); ** allocated. ** ****************************************************************/ -void *test_vltypes_alloc_custom(size_t size, void *mem_used) +void * +test_vltypes_alloc_custom(size_t size, void *mem_used) { - void *ret_value; /* Pointer to return */ + void * ret_value; /* Pointer to return */ const size_t extra = MAX(sizeof(void *), sizeof(size_t)); /* Extra space needed */ - /* (This weird contortion is required on the - * DEC Alpha to keep the alignment correct - QAK) - */ + /* (This weird contortion is required on the + * DEC Alpha to keep the alignment correct - QAK) + */ - if((ret_value = HDmalloc(extra + size)) != NULL) { + if ((ret_value = HDmalloc(extra + size)) != NULL) { *(size_t *)ret_value = size; *(size_t *)mem_used += size; } /* end if */ ret_value = ((unsigned char *)ret_value) + extra; - return(ret_value); + return (ret_value); } /**************************************************************** @@ -78,15 +79,16 @@ void *test_vltypes_alloc_custom(size_t size, void *mem_used) ** allocated. ** ****************************************************************/ -void test_vltypes_free_custom(void *_mem, void *mem_used) +void +test_vltypes_free_custom(void *_mem, void *mem_used) { - if(_mem) { - const size_t extra = MAX(sizeof(void *), sizeof(size_t)); /* Extra space needed */ - /* (This weird contortion is required - * on the DEC Alpha to keep the - * alignment correct - QAK) - */ - unsigned char *mem = ((unsigned char *)_mem) - extra; /* Pointer to actual block allocated */ + if (_mem) { + const size_t extra = MAX(sizeof(void *), sizeof(size_t)); /* Extra space needed */ + /* (This weird contortion is required + * on the DEC Alpha to keep the + * alignment correct - QAK) + */ + unsigned char *mem = ((unsigned char *)_mem) - extra; /* Pointer to actual block allocated */ *(size_t *)mem_used -= *(size_t *)((void *)mem); HDfree(mem); @@ -102,13 +104,13 @@ void test_vltypes_free_custom(void *_mem, void *mem_used) static void test_vltypes_dataset_create(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dcpl; /* Dataset Property list */ - hid_t dataset; /* Dataset ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dcpl; /* Dataset Property list */ + hid_t dataset; /* Dataset ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataset of VL Datatype Functionality\n")); @@ -134,9 +136,8 @@ test_vltypes_dataset_create(void) CHECK(ret, FAIL, "H5Pset_fill_time"); /* Create a dataset, supposed to fail */ - H5E_BEGIN_TRY { - dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; + H5E_BEGIN_TRY { dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, dcpl, H5P_DEFAULT); } + H5E_END_TRY; VERIFY(dataset, FAIL, "H5Dcreate2"); /* Close datatype */ @@ -165,19 +166,19 @@ test_vltypes_dataset_create(void) static void test_vltypes_funcs(void) { - hid_t type; /* Datatype ID */ - size_t size; - H5T_pad_t inpad; - H5T_norm_t norm; - H5T_cset_t cset; - H5T_str_t strpad; - herr_t ret; /* Generic return value */ + hid_t type; /* Datatype ID */ + size_t size; + H5T_pad_t inpad; + H5T_norm_t norm; + H5T_cset_t cset; + H5T_str_t strpad; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing some type functions for VL\n")); /* Create a datatype to refer to */ - type = H5Tvlen_create (H5T_IEEE_F32BE); + type = H5Tvlen_create(H5T_IEEE_F32BE); CHECK(type, FAIL, "H5Tvlen_create"); size = H5Tget_precision(type); @@ -201,14 +202,12 @@ test_vltypes_funcs(void) ret = H5Tset_offset(type, (size_t)16); CHECK(ret, FAIL, "H5Tset_offset"); - H5E_BEGIN_TRY { - cset = H5Tget_cset(type); - } H5E_END_TRY; + H5E_BEGIN_TRY { cset = H5Tget_cset(type); } + H5E_END_TRY; VERIFY(cset, FAIL, "H5Tget_cset"); - H5E_BEGIN_TRY { - strpad=H5Tget_strpad(type); - } H5E_END_TRY; + H5E_BEGIN_TRY { strpad = H5Tget_strpad(type); } + H5E_END_TRY; VERIFY(strpad, FAIL, "H5Tget_strpad"); /* Close datatype */ @@ -225,35 +224,35 @@ test_vltypes_funcs(void) static void test_vltypes_vlen_atomic(void) { - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t wdata2[SPACE1_DIM1]; /* Information to write */ - hvl_t rdata[SPACE1_DIM1]; /* Information read in */ - hvl_t fill; /* Fill value */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t sid2; /* ID of bad dataspace (no extent set) */ - hid_t tid1; /* Datatype ID */ - hid_t dcpl_pid; /* Dataset creation property list ID */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t wdata2[SPACE1_DIM1]; /* Information to write */ + hvl_t rdata[SPACE1_DIM1]; /* Information read in */ + hvl_t fill; /* Fill value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t sid2; /* ID of bad dataspace (no extent set) */ + hid_t tid1; /* Datatype ID */ + hid_t dcpl_pid; /* Dataset creation property list ID */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Atomic VL Datatype Functionality\n")); /* Allocate and initialize VL data to write */ - for(i=0; i<SPACE1_DIM1; i++) { - wdata[i].p=HDmalloc((i+1)*sizeof(unsigned int)); - wdata[i].len=i+1; - for(j=0; j<(i+1); j++) - ((unsigned int *)wdata[i].p)[j]=i*10+j; - - wdata2[i].p=NULL; - wdata2[i].len=0; + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].p = HDmalloc((i + 1) * sizeof(unsigned int)); + wdata[i].len = i + 1; + for (j = 0; j < (i + 1); j++) + ((unsigned int *)wdata[i].p)[j] = i * 10 + j; + + wdata2[i].p = NULL; + wdata2[i].len = 0; } /* end for */ /* Create file */ @@ -265,7 +264,7 @@ test_vltypes_vlen_atomic(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a datatype to refer to */ - tid1 = H5Tvlen_create (H5T_NATIVE_UINT); + tid1 = H5Tvlen_create(H5T_NATIVE_UINT); CHECK(tid1, FAIL, "H5Tvlen_create"); /* Create a dataset */ @@ -277,9 +276,10 @@ test_vltypes_vlen_atomic(void) CHECK(ret, FAIL, "H5Dread"); /* Check data read in */ - for(i = 0; i < SPACE1_DIM1; i++) - if(rdata[i].len != 0 || rdata[i].p != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d].len=%u, rdata[%d].p=%p\n",(int)i,(unsigned)rdata[i].len,(int)i,rdata[i].p); + for (i = 0; i < SPACE1_DIM1; i++) + if (rdata[i].len != 0 || rdata[i].p != NULL) + TestErrPrintf("VL doesn't match!, rdata[%d].len=%u, rdata[%d].p=%p\n", (int)i, + (unsigned)rdata[i].len, (int)i, rdata[i].p); /* Write "nil" data to disk */ ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata2); @@ -290,9 +290,10 @@ test_vltypes_vlen_atomic(void) CHECK(ret, FAIL, "H5Dread"); /* Check data read in */ - for(i = 0; i < SPACE1_DIM1; i++) - if(rdata[i].len != 0 || rdata[i].p != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d].len=%u, rdata[%d].p=%p\n",(int)i,(unsigned)rdata[i].len,(int)i,rdata[i].p); + for (i = 0; i < SPACE1_DIM1; i++) + if (rdata[i].len != 0 || rdata[i].p != NULL) + TestErrPrintf("VL doesn't match!, rdata[%d].len=%u, rdata[%d].p=%p\n", (int)i, + (unsigned)rdata[i].len, (int)i, rdata[i].p); /* Write dataset to disk */ ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); @@ -307,8 +308,9 @@ test_vltypes_vlen_atomic(void) CHECK(dcpl_pid, FAIL, "H5Pcreate"); /* Set the fill value for the second dataset */ - fill.p = NULL; fill.len = 0; - ret = H5Pset_fill_value(dcpl_pid, tid1, &fill); + fill.p = NULL; + fill.len = 0; + ret = H5Pset_fill_value(dcpl_pid, tid1, &fill); CHECK(ret, FAIL, "H5Pset_fill_value"); /* Create a second dataset */ @@ -324,9 +326,10 @@ test_vltypes_vlen_atomic(void) CHECK(ret, FAIL, "H5Dread"); /* Check data read in */ - for(i = 0; i < SPACE1_DIM1; i++) - if(rdata[i].len != 0 || rdata[i].p != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d].len=%u, rdata[%d].p=%p\n",(int)i,(unsigned)rdata[i].len,(int)i,rdata[i].p); + for (i = 0; i < SPACE1_DIM1; i++) + if (rdata[i].len != 0 || rdata[i].p != NULL) + TestErrPrintf("VL doesn't match!, rdata[%d].len=%u, rdata[%d].p=%p\n", (int)i, + (unsigned)rdata[i].len, (int)i, rdata[i].p); /* Write "nil" data to disk */ ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata2); @@ -337,9 +340,10 @@ test_vltypes_vlen_atomic(void) CHECK(ret, FAIL, "H5Dread"); /* Check data read in */ - for(i=0; i<SPACE1_DIM1; i++) - if(rdata[i].len != 0 || rdata[i].p != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d].len=%u, rdata[%d].p=%p\n",(int)i,(unsigned)rdata[i].len,(int)i,rdata[i].p); + for (i = 0; i < SPACE1_DIM1; i++) + if (rdata[i].len != 0 || rdata[i].p != NULL) + TestErrPrintf("VL doesn't match!, rdata[%d].len=%u, rdata[%d].p=%p\n", (int)i, + (unsigned)rdata[i].len, (int)i, rdata[i].p); /* Write data to disk */ ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); @@ -361,7 +365,6 @@ test_vltypes_vlen_atomic(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open the file for data checking */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -382,7 +385,8 @@ test_vltypes_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory will be used */ @@ -390,7 +394,7 @@ test_vltypes_vlen_atomic(void) CHECK(ret, FAIL, "H5Dvlen_get_buf_size"); /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ - VERIFY(size,((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(unsigned int), "H5Dvlen_get_buf_size"); + VERIFY(size, ((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(unsigned int), "H5Dvlen_get_buf_size"); /* Read dataset from disk */ ret = H5Dread(dataset, tid1, H5S_ALL, H5S_ALL, xfer_pid, rdata); @@ -398,21 +402,24 @@ test_vltypes_vlen_atomic(void) /* Make certain the correct amount of memory has been used */ /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ - VERIFY(mem_used,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(unsigned int),"H5Dread"); + VERIFY(mem_used, ((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(unsigned int), "H5Dread"); /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata[i].len!=rdata[i].len) { - TestErrPrintf("%d: VL data lengths don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",__LINE__,(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].len != rdata[i].len) { + TestErrPrintf("%d: VL data lengths don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n", __LINE__, + (int)i, (int)wdata[i].len, (int)i, (int)rdata[i].len); continue; } /* end if */ - for(j=0; j<rdata[i].len; j++) { - if( ((unsigned int *)wdata[i].p)[j] != ((unsigned int *)rdata[i].p)[j] ) { - TestErrPrintf("VL data values don't match!, wdata[%d].p[%d]=%d, rdata[%d].p[%d]=%d\n",(int)i,(int)j, (int)((unsigned int *)wdata[i].p)[j], (int)i,(int)j, (int)((unsigned int *)rdata[i].p)[j]); + for (j = 0; j < rdata[i].len; j++) { + if (((unsigned int *)wdata[i].p)[j] != ((unsigned int *)rdata[i].p)[j]) { + TestErrPrintf("VL data values don't match!, wdata[%d].p[%d]=%d, rdata[%d].p[%d]=%d\n", (int)i, + (int)j, (int)((unsigned int *)wdata[i].p)[j], (int)i, (int)j, + (int)((unsigned int *)rdata[i].p)[j]); continue; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim the read VL data */ ret = H5Treclaim(tid1, sid1, xfer_pid, rdata); @@ -437,7 +444,6 @@ test_vltypes_vlen_atomic(void) ret = H5Pclose(xfer_pid); CHECK(ret, FAIL, "H5Pclose"); - /* Open second dataset */ dataset = H5Dopen2(fid1, "Dataset2", H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dopen2"); @@ -458,7 +464,8 @@ test_vltypes_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory will be used */ @@ -466,56 +473,57 @@ test_vltypes_vlen_atomic(void) CHECK(ret, FAIL, "H5Dvlen_get_buf_size"); /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ - VERIFY(size,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(unsigned int),"H5Dvlen_get_buf_size"); + VERIFY(size, ((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(unsigned int), "H5Dvlen_get_buf_size"); /* Try to call H5Dvlen_get_buf with bad dataspace */ - H5E_BEGIN_TRY { - ret = H5Dvlen_get_buf_size(dataset, tid1, sid2, &size); - } H5E_END_TRY + H5E_BEGIN_TRY { ret = H5Dvlen_get_buf_size(dataset, tid1, sid2, &size); } + H5E_END_TRY VERIFY(ret, FAIL, "H5Dvlen_get_buf_size"); /* Read dataset from disk */ - ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,xfer_pid,rdata); + ret = H5Dread(dataset, tid1, H5S_ALL, H5S_ALL, xfer_pid, rdata); CHECK(ret, FAIL, "H5Dread"); /* Make certain the correct amount of memory has been used */ /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ - VERIFY(mem_used,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(unsigned int),"H5Dread"); + VERIFY(mem_used, ((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(unsigned int), "H5Dread"); /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata[i].len!=rdata[i].len) { - TestErrPrintf("%d: VL data lengths don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",__LINE__,(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].len != rdata[i].len) { + TestErrPrintf("%d: VL data lengths don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n", __LINE__, + (int)i, (int)wdata[i].len, (int)i, (int)rdata[i].len); continue; } /* end if */ - for(j=0; j<rdata[i].len; j++) { - if( ((unsigned int *)wdata[i].p)[j] != ((unsigned int *)rdata[i].p)[j] ) { - TestErrPrintf("VL data values don't match!, wdata[%d].p[%d]=%d, rdata[%d].p[%d]=%d\n",(int)i,(int)j, (int)((unsigned int *)wdata[i].p)[j], (int)i,(int)j, (int)((unsigned int *)rdata[i].p)[j]); + for (j = 0; j < rdata[i].len; j++) { + if (((unsigned int *)wdata[i].p)[j] != ((unsigned int *)rdata[i].p)[j]) { + TestErrPrintf("VL data values don't match!, wdata[%d].p[%d]=%d, rdata[%d].p[%d]=%d\n", (int)i, + (int)j, (int)((unsigned int *)wdata[i].p)[j], (int)i, (int)j, + (int)((unsigned int *)rdata[i].p)[j]); continue; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Try to reclaim read data using "bad" dataspace with no extent * Should fail */ - H5E_BEGIN_TRY { - ret=H5Treclaim(tid1,sid2,xfer_pid,rdata); - } H5E_END_TRY + H5E_BEGIN_TRY { ret = H5Treclaim(tid1, sid2, xfer_pid, rdata); } + H5E_END_TRY VERIFY(ret, FAIL, "H5Treclaim"); /* Reclaim the read VL data */ - ret=H5Treclaim(tid1,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid1, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Close Dataset */ ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid1,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid1, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close datatype */ @@ -545,27 +553,27 @@ test_vltypes_vlen_atomic(void) static void rewrite_vltypes_vlen_atomic(void) { - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t rdata[SPACE1_DIM1]; /* Information read in */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - unsigned increment=4; - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t rdata[SPACE1_DIM1]; /* Information read in */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + unsigned increment = 4; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Check Memory Leak for Basic Atomic VL Datatype Functionality\n")); /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { - wdata[i].p = HDmalloc((i + increment) * sizeof(unsigned int)); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].p = HDmalloc((i + increment) * sizeof(unsigned int)); wdata[i].len = i + increment; - for(j = 0; j < (i + increment); j++) + for (j = 0; j < (i + increment); j++) ((unsigned int *)wdata[i].p)[j] = i * 20 + j; } /* end for */ @@ -605,7 +613,6 @@ rewrite_vltypes_vlen_atomic(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open the file for data checking */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -626,7 +633,8 @@ rewrite_vltypes_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory will be used */ @@ -645,28 +653,31 @@ rewrite_vltypes_vlen_atomic(void) VERIFY(mem_used, 22 * sizeof(unsigned int), "H5Dread"); /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata[i].len!=rdata[i].len) { - TestErrPrintf("%d: VL data lengths don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",__LINE__,(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].len != rdata[i].len) { + TestErrPrintf("%d: VL data lengths don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n", __LINE__, + (int)i, (int)wdata[i].len, (int)i, (int)rdata[i].len); continue; } /* end if */ - for(j=0; j<rdata[i].len; j++) { - if( ((unsigned int *)wdata[i].p)[j] != ((unsigned int *)rdata[i].p)[j] ) { - TestErrPrintf("VL data values don't match!, wdata[%d].p[%d]=%d, rdata[%d].p[%d]=%d\n",(int)i,(int)j, (int)((unsigned int *)wdata[i].p)[j], (int)i,(int)j, (int)((unsigned int *)rdata[i].p)[j]); + for (j = 0; j < rdata[i].len; j++) { + if (((unsigned int *)wdata[i].p)[j] != ((unsigned int *)rdata[i].p)[j]) { + TestErrPrintf("VL data values don't match!, wdata[%d].p[%d]=%d, rdata[%d].p[%d]=%d\n", (int)i, + (int)j, (int)((unsigned int *)wdata[i].p)[j], (int)i, (int)j, + (int)((unsigned int *)rdata[i].p)[j]); continue; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim the read VL data */ - ret=H5Treclaim(tid1,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid1, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid1,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid1, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -691,8 +702,6 @@ rewrite_vltypes_vlen_atomic(void) } /* end rewrite_vltypes_vlen_atomic() */ - - /**************************************************************** ** ** test_vltypes_vlen_compound(): Test basic VL datatype code. @@ -702,35 +711,35 @@ rewrite_vltypes_vlen_atomic(void) static void test_vltypes_vlen_compound(void) { - typedef struct { /* Struct that the VL sequences are composed of */ - int i; + typedef struct { /* Struct that the VL sequences are composed of */ + int i; float f; } s1; - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t rdata[SPACE1_DIM1]; /* Information read in */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t rdata[SPACE1_DIM1]; /* Information read in */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Compound VL Datatype Functionality\n")); /* Allocate and initialize VL data to write */ - for(i=0; i<SPACE1_DIM1; i++) { - wdata[i].p=HDmalloc((i+1)*sizeof(s1)); - wdata[i].len=i+1; - for(j=0; j<(i+1); j++) { + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].p = HDmalloc((i + 1) * sizeof(s1)); + wdata[i].len = i + 1; + for (j = 0; j < (i + 1); j++) { ((s1 *)wdata[i].p)[j].i = (int)(i * 10 + j); ((s1 *)wdata[i].p)[j].f = (float)(i * 20 + j) / 3.0F; - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Create file */ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -766,7 +775,8 @@ test_vltypes_vlen_compound(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory will be used */ @@ -782,35 +792,40 @@ test_vltypes_vlen_compound(void) /* Make certain the correct amount of memory has been used */ /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ - VERIFY(mem_used,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(s1),"H5Dread"); + VERIFY(mem_used, ((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(s1), "H5Dread"); /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata[i].len!=rdata[i].len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",__LINE__,(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].len != rdata[i].len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n", __LINE__, + (int)i, (int)wdata[i].len, (int)i, (int)rdata[i].len); continue; } /* end if */ - for(j=0; j<rdata[i].len; j++) { - if(((s1 *)wdata[i].p)[j].i != ((s1 *)rdata[i].p)[j].i ) { - TestErrPrintf("VL data values don't match!, wdata[%d].p[%d].i=%d, rdata[%d].p[%d].i=%d\n",(int)i,(int)j, (int)((s1 *)wdata[i].p)[j].i, (int)i,(int)j, (int)((s1 *)rdata[i].p)[j].i); + for (j = 0; j < rdata[i].len; j++) { + if (((s1 *)wdata[i].p)[j].i != ((s1 *)rdata[i].p)[j].i) { + TestErrPrintf("VL data values don't match!, wdata[%d].p[%d].i=%d, rdata[%d].p[%d].i=%d\n", + (int)i, (int)j, (int)((s1 *)wdata[i].p)[j].i, (int)i, (int)j, + (int)((s1 *)rdata[i].p)[j].i); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(((s1 *)wdata[i].p)[j].f,((s1 *)rdata[i].p)[j].f)) { - TestErrPrintf("VL data values don't match!, wdata[%d].p[%d].f=%f, rdata[%d].p[%d].f=%f\n",(int)i,(int)j, (double)((s1 *)wdata[i].p)[j].f, (int)i,(int)j, (double)((s1 *)rdata[i].p)[j].f); + if (!H5_FLT_ABS_EQUAL(((s1 *)wdata[i].p)[j].f, ((s1 *)rdata[i].p)[j].f)) { + TestErrPrintf("VL data values don't match!, wdata[%d].p[%d].f=%f, rdata[%d].p[%d].f=%f\n", + (int)i, (int)j, (double)((s1 *)wdata[i].p)[j].f, (int)i, (int)j, + (double)((s1 *)rdata[i].p)[j].f); continue; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim the VL data */ - ret=H5Treclaim(tid1,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid1, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid1,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid1, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -848,35 +863,35 @@ test_vltypes_vlen_compound(void) static void rewrite_vltypes_vlen_compound(void) { - typedef struct { /* Struct that the VL sequences are composed of */ - int i; + typedef struct { /* Struct that the VL sequences are composed of */ + int i; float f; } s1; - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t rdata[SPACE1_DIM1]; /* Information read in */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - unsigned increment=4; - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t rdata[SPACE1_DIM1]; /* Information read in */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + unsigned increment = 4; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Check Memory Leak for Basic Compound VL Datatype Functionality\n")); /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { - wdata[i].p = HDmalloc((i + increment) * sizeof(s1)); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].p = HDmalloc((i + increment) * sizeof(s1)); wdata[i].len = i + increment; - for(j = 0; j < (i + increment); j++) { + for (j = 0; j < (i + increment); j++) { ((s1 *)wdata[i].p)[j].i = (int)(i * 40 + j); ((s1 *)wdata[i].p)[j].f = (float)(i * 60 + j) / 3.0F; - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Create file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); @@ -892,7 +907,7 @@ rewrite_vltypes_vlen_compound(void) CHECK(ret, FAIL, "H5Tinsert"); /* Create a datatype to refer to */ - tid1 = H5Tvlen_create (tid2); + tid1 = H5Tvlen_create(tid2); CHECK(tid1, FAIL, "H5Tvlen_create"); /* Create a dataset */ @@ -911,7 +926,8 @@ rewrite_vltypes_vlen_compound(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory will be used */ @@ -922,40 +938,45 @@ rewrite_vltypes_vlen_compound(void) VERIFY(size, 22 * sizeof(s1), "H5Dvlen_get_buf_size"); /* Read dataset from disk */ - ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,xfer_pid,rdata); + ret = H5Dread(dataset, tid1, H5S_ALL, H5S_ALL, xfer_pid, rdata); CHECK(ret, FAIL, "H5Dread"); /* Make certain the correct amount of memory has been used */ /* 22 elements allocated = 4 + 5 + 6 + 7 elements for each array position */ - VERIFY(mem_used,22*sizeof(s1),"H5Dread"); + VERIFY(mem_used, 22 * sizeof(s1), "H5Dread"); /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata[i].len!=rdata[i].len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",__LINE__,(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].len != rdata[i].len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n", __LINE__, + (int)i, (int)wdata[i].len, (int)i, (int)rdata[i].len); continue; } /* end if */ - for(j=0; j<rdata[i].len; j++) { - if( ((s1 *)wdata[i].p)[j].i != ((s1 *)rdata[i].p)[j].i ) { - TestErrPrintf("VL data values don't match!, wdata[%d].p[%d].i=%d, rdata[%d].p[%d].i=%d\n",(int)i,(int)j, (int)((s1 *)wdata[i].p)[j].i, (int)i,(int)j, (int)((s1 *)rdata[i].p)[j].i); + for (j = 0; j < rdata[i].len; j++) { + if (((s1 *)wdata[i].p)[j].i != ((s1 *)rdata[i].p)[j].i) { + TestErrPrintf("VL data values don't match!, wdata[%d].p[%d].i=%d, rdata[%d].p[%d].i=%d\n", + (int)i, (int)j, (int)((s1 *)wdata[i].p)[j].i, (int)i, (int)j, + (int)((s1 *)rdata[i].p)[j].i); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(((s1 *)wdata[i].p)[j].f,((s1 *)rdata[i].p)[j].f)) { - TestErrPrintf("VL data values don't match!, wdata[%d].p[%d].f=%f, rdata[%d].p[%d].f=%f\n",(int)i,(int)j, (double)((s1 *)wdata[i].p)[j].f, (int)i,(int)j, (double)((s1 *)rdata[i].p)[j].f); + if (!H5_FLT_ABS_EQUAL(((s1 *)wdata[i].p)[j].f, ((s1 *)rdata[i].p)[j].f)) { + TestErrPrintf("VL data values don't match!, wdata[%d].p[%d].f=%f, rdata[%d].p[%d].f=%f\n", + (int)i, (int)j, (double)((s1 *)wdata[i].p)[j].f, (int)i, (int)j, + (double)((s1 *)rdata[i].p)[j].f); continue; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim the VL data */ - ret=H5Treclaim(tid1,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid1, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid1,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid1, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -993,21 +1014,21 @@ rewrite_vltypes_vlen_compound(void) static void test_vltypes_compound_vlen_vlen(void) { - typedef struct { /* Struct that the compound type are composed of */ - int i; + typedef struct { /* Struct that the compound type are composed of */ + int i; float f; hvl_t v; } s1; - s1 *wdata; /* data to write */ - s1 *rdata; /* data to read */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2, tid3; /* Datatype IDs */ - hsize_t dims1[] = {SPACE3_DIM1}; - unsigned i,j,k; /* counting variables */ - hvl_t *t1, *t2; /* Temporary pointer to VL information */ - herr_t ret; /* Generic return value */ + s1 * wdata; /* data to write */ + s1 * rdata; /* data to read */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2, tid3; /* Datatype IDs */ + hsize_t dims1[] = {SPACE3_DIM1}; + unsigned i, j, k; /* counting variables */ + hvl_t * t1, *t2; /* Temporary pointer to VL information */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Compound Datatypes with VL Atomic Datatype Component Functionality\n")); @@ -1017,18 +1038,18 @@ test_vltypes_compound_vlen_vlen(void) CHECK_PTR(wdata, "HDmalloc"); rdata = (s1 *)HDmalloc(sizeof(s1) * SPACE3_DIM1); CHECK_PTR(rdata, "HDmalloc"); - for(i = 0; i < SPACE3_DIM1; i++) { - wdata[i].i = (int)(i * 10); - wdata[i].f = (float)(i * 20) / 3.0F; - wdata[i].v.p = HDmalloc((i + L1_INCM) * sizeof(hvl_t)); + for (i = 0; i < SPACE3_DIM1; i++) { + wdata[i].i = (int)(i * 10); + wdata[i].f = (float)(i * 20) / 3.0F; + wdata[i].v.p = HDmalloc((i + L1_INCM) * sizeof(hvl_t)); wdata[i].v.len = i + L1_INCM; - for(t1 = (hvl_t *)((wdata[i].v).p), j = 0; j < (i + L1_INCM); j++, t1++) { - t1->p = HDmalloc((j + L2_INCM) * sizeof(unsigned int)); + for (t1 = (hvl_t *)((wdata[i].v).p), j = 0; j < (i + L1_INCM); j++, t1++) { + t1->p = HDmalloc((j + L2_INCM) * sizeof(unsigned int)); t1->len = j + L2_INCM; - for(k = 0; k < j + L2_INCM; k++) - ((unsigned int*)t1->p)[k] = i * 100 + j * 10 + k; + for (k = 0; k < j + L2_INCM; k++) + ((unsigned int *)t1->p)[k] = i * 100 + j * 10 + k; } /* end for */ - } /* end for */ + } /* end for */ /* Create file */ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1039,11 +1060,11 @@ test_vltypes_compound_vlen_vlen(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a VL datatype to refer to */ - tid3 = H5Tvlen_create (H5T_NATIVE_UINT); + tid3 = H5Tvlen_create(H5T_NATIVE_UINT); CHECK(tid3, FAIL, "H5Tvlen_create"); /* Create a VL datatype to refer to */ - tid1 = H5Tvlen_create (tid3); + tid1 = H5Tvlen_create(tid3); CHECK(tid1, FAIL, "H5Tvlen_create"); /* Create the base compound type */ @@ -1074,7 +1095,6 @@ test_vltypes_compound_vlen_vlen(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -1088,41 +1108,47 @@ test_vltypes_compound_vlen_vlen(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < SPACE3_DIM1; i++) { - if(wdata[i].i != rdata[i].i) { - TestErrPrintf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n",(int)i,(int)wdata[i].i,(int)i,(int)rdata[i].i); + for (i = 0; i < SPACE3_DIM1; i++) { + if (wdata[i].i != rdata[i].i) { + TestErrPrintf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n", (int)i, + (int)wdata[i].i, (int)i, (int)rdata[i].i); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(wdata[i].f,rdata[i].f)) { - TestErrPrintf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n",(int)i,(double)wdata[i].f,(int)i,(double)rdata[i].f); + if (!H5_FLT_ABS_EQUAL(wdata[i].f, rdata[i].f)) { + TestErrPrintf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n", (int)i, + (double)wdata[i].f, (int)i, (double)rdata[i].f); continue; } /* end if */ - if(wdata[i].v.len != rdata[i].v.len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n",__LINE__,(int)i,(int)wdata[i].v.len,(int)i,(int)rdata[i].v.len); + if (wdata[i].v.len != rdata[i].v.len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n", + __LINE__, (int)i, (int)wdata[i].v.len, (int)i, (int)rdata[i].v.len); continue; } /* end if */ - for(t1=(hvl_t *)(wdata[i].v.p), t2=(hvl_t *)(rdata[i].v.p), j=0; j<rdata[i].v.len; j++, t1++, t2++) { - if(t1->len != t2->len) { - TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + for (t1 = (hvl_t *)(wdata[i].v.p), t2 = (hvl_t *)(rdata[i].v.p), j = 0; j < rdata[i].v.len; + j++, t1++, t2++) { + if (t1->len != t2->len) { + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n", + __LINE__, (int)i, (int)j, (int)t1->len, (int)t2->len); continue; } /* end if */ - for(k=0; k<t2->len; k++) { - if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + for (k = 0; k < t2->len; k++) { + if (((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k]) { + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n", (int)k, + (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim the VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -1165,48 +1191,44 @@ test_vltypes_compound_vlen_vlen(void) static void test_vltypes_compound_vlstr(void) { - typedef enum { - red, - blue, - green - } e1; + typedef enum { red, blue, green } e1; typedef struct { char *string; - e1 color; + e1 color; } s2; - typedef struct { /* Struct that the compound type are composed of */ + typedef struct { /* Struct that the compound type are composed of */ hvl_t v; } s1; - s1 wdata[SPACE1_DIM1]; /* data to write */ - s1 wdata2[SPACE1_DIM1]; /* data to write */ - s1 rdata[SPACE1_DIM1]; /* data to read */ - s1 rdata2[SPACE1_DIM1]; /* data to read */ - char str[64] = "a\0"; - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, dset2; /* Dataset ID */ - hid_t sid1, sid2, filespace, filespace2; /* Dataspace ID */ - hid_t tid1, tid2, tid3, tid4, tid5; /* Datatype IDs */ + s1 wdata[SPACE1_DIM1]; /* data to write */ + s1 wdata2[SPACE1_DIM1]; /* data to write */ + s1 rdata[SPACE1_DIM1]; /* data to read */ + s1 rdata2[SPACE1_DIM1]; /* data to read */ + char str[64] = "a\0"; + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, dset2; /* Dataset ID */ + hid_t sid1, sid2, filespace, filespace2; /* Dataspace ID */ + hid_t tid1, tid2, tid3, tid4, tid5; /* Datatype IDs */ hid_t cparms; - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t chunk_dims[] = {SPACE1_DIM1/2}; - hsize_t maxdims[] = {H5S_UNLIMITED}; - hsize_t size[] = {SPACE1_DIM1}; - hsize_t offset[] = {0}; - unsigned i,j; /* counting variables */ - s2 *t1, *t2; /* Temporary pointer to VL information */ - int val; - herr_t ret; /* Generic return value */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t chunk_dims[] = {SPACE1_DIM1 / 2}; + hsize_t maxdims[] = {H5S_UNLIMITED}; + hsize_t size[] = {SPACE1_DIM1}; + hsize_t offset[] = {0}; + unsigned i, j; /* counting variables */ + s2 * t1, *t2; /* Temporary pointer to VL information */ + int val; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing VL Datatype of Compound Datatype with VL String Functionality\n")); /* Allocate and initialize VL data to write */ - for(i=0; i<SPACE1_DIM1; i++) { - wdata[i].v.p=(s2*)HDmalloc((i+L3_INCM)*sizeof(s2)); - wdata[i].v.len=i+L3_INCM; - for(t1=(s2 *)((wdata[i].v).p), j=0; j<(i+L3_INCM); j++, t1++) { + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].v.p = (s2 *)HDmalloc((i + L3_INCM) * sizeof(s2)); + wdata[i].v.len = i + L3_INCM; + for (t1 = (s2 *)((wdata[i].v).p), j = 0; j < (i + L3_INCM); j++, t1++) { HDstrcat(str, "m"); - t1->string = (char*)HDmalloc(HDstrlen(str)*sizeof(char)+1); + t1->string = (char *)HDmalloc(HDstrlen(str) * sizeof(char) + 1); HDstrcpy(t1->string, str); /*t1->color = red;*/ t1->color = blue; @@ -1222,15 +1244,15 @@ test_vltypes_compound_vlstr(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a VL string type*/ - tid4 = H5Tcopy (H5T_C_S1); + tid4 = H5Tcopy(H5T_C_S1); CHECK(tid4, FAIL, "H5Tcopy"); - ret = H5Tset_size (tid4,H5T_VARIABLE); + ret = H5Tset_size(tid4, H5T_VARIABLE); CHECK(ret, FAIL, "H5Tset_size"); /* Create an enum type */ tid3 = H5Tenum_create(H5T_STD_I32LE); - val = 0; - ret = H5Tenum_insert(tid3, "RED", &val); + val = 0; + ret = H5Tenum_insert(tid3, "RED", &val); CHECK(ret, FAIL, "H5Tenum_insert"); val = 1; ret = H5Tenum_insert(tid3, "BLUE", &val); @@ -1243,13 +1265,12 @@ test_vltypes_compound_vlstr(void) tid5 = H5Tcreate(H5T_COMPOUND, sizeof(s2)); CHECK(tid5, FAIL, "H5Tcreate"); /* Insert fields */ - ret=H5Tinsert(tid5, "string", HOFFSET(s2, string), tid4); + ret = H5Tinsert(tid5, "string", HOFFSET(s2, string), tid4); CHECK(ret, FAIL, "H5Tinsert"); /* Insert fields */ - ret=H5Tinsert(tid5, "enumerate", HOFFSET(s2, color), tid3); + ret = H5Tinsert(tid5, "enumerate", HOFFSET(s2, color), tid3); CHECK(ret, FAIL, "H5Tinsert"); - /* Create a VL datatype of first layer compound type */ tid1 = H5Tvlen_create(tid5); CHECK(tid1, FAIL, "H5Tvlen_create"); @@ -1264,7 +1285,7 @@ test_vltypes_compound_vlstr(void) /* Modify dataset creation properties, i.e. enable chunking */ cparms = H5Pcreate(H5P_DATASET_CREATE); - ret = H5Pset_chunk(cparms, SPACE1_RANK, chunk_dims); + ret = H5Pset_chunk(cparms, SPACE1_RANK, chunk_dims); CHECK(ret, FAIL, "H5Pset_chunk"); /* Create a dataset */ @@ -1277,7 +1298,7 @@ test_vltypes_compound_vlstr(void) /* Select a hyperslab */ filespace = H5Dget_space(dataset); - ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims1, NULL); + ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims1, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Write dataset to disk */ @@ -1323,7 +1344,6 @@ test_vltypes_compound_vlstr(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -1341,49 +1361,52 @@ test_vltypes_compound_vlstr(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < SPACE1_DIM1; i++) { - if(wdata[i].v.len != rdata[i].v.len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n",__LINE__,(int)i,(int)wdata[i].v.len,(int)i,(int)rdata[i].v.len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].v.len != rdata[i].v.len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n", + __LINE__, (int)i, (int)wdata[i].v.len, (int)i, (int)rdata[i].v.len); continue; } /* end if */ - for(t1=(s2 *)(wdata[i].v.p), t2=(s2 *)(rdata[i].v.p), j=0; j<rdata[i].v.len; j++, t1++, t2++) { - if(HDstrcmp(t1->string, t2->string)) { - TestErrPrintf("VL data values don't match!, t1->string=%s, t2->string=%s\n",t1->string, t2->string); - continue; - } /* end if */ - if(t1->color != t2->color) { - TestErrPrintf("VL data values don't match!, t1->color=%d, t2->color=%d\n",t1->color, t2->color); - continue; - } /* end if */ - } /* end for */ - } /* end for */ + for (t1 = (s2 *)(wdata[i].v.p), t2 = (s2 *)(rdata[i].v.p), j = 0; j < rdata[i].v.len; + j++, t1++, t2++) { + if (HDstrcmp(t1->string, t2->string)) { + TestErrPrintf("VL data values don't match!, t1->string=%s, t2->string=%s\n", t1->string, + t2->string); + continue; + } /* end if */ + if (t1->color != t2->color) { + TestErrPrintf("VL data values don't match!, t1->color=%d, t2->color=%d\n", t1->color, + t2->color); + continue; + } /* end if */ + } /* end for */ + } /* end for */ /* Reclaim the VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Use this part for new data */ HDstrcpy(str, "bbbbbbbb\0"); - for(i=0; i<SPACE1_DIM1; i++) { - wdata2[i].v.p=(s2*)HDmalloc((i+1)*sizeof(s2)); - wdata2[i].v.len=i+1; - for(t1=(s2*)(wdata2[i].v).p, j=0; j<i+1; j++, t1++) { - HDstrcat(str, "pp"); - t1->string = (char*)HDmalloc(HDstrlen(str)*sizeof(char)+1); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata2[i].v.p = (s2 *)HDmalloc((i + 1) * sizeof(s2)); + wdata2[i].v.len = i + 1; + for (t1 = (s2 *)(wdata2[i].v).p, j = 0; j < i + 1; j++, t1++) { + HDstrcat(str, "pp"); + t1->string = (char *)HDmalloc(HDstrlen(str) * sizeof(char) + 1); HDstrcpy(t1->string, str); - t1->color = green; + t1->color = green; } } /* end for */ /* Select a hyperslab */ - filespace2 = H5Dget_space (dset2); - ret = H5Sselect_hyperslab (filespace2, H5S_SELECT_SET, offset, NULL, - dims1, NULL); + filespace2 = H5Dget_space(dset2); + ret = H5Sselect_hyperslab(filespace2, H5S_SELECT_SET, offset, NULL, dims1, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for datasets */ @@ -1391,38 +1414,42 @@ test_vltypes_compound_vlstr(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Write dataset to disk */ - ret=H5Dwrite(dset2,tid2,sid2,filespace2,H5P_DEFAULT, &wdata2); + ret = H5Dwrite(dset2, tid2, sid2, filespace2, H5P_DEFAULT, &wdata2); CHECK(ret, FAIL, "H5Dwrite"); /* Read dataset from disk */ - ret=H5Dread(dset2,tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata2); + ret = H5Dread(dset2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata2); CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata2[i].v.len!=rdata2[i].v.len) { - TestErrPrintf("%d: VL data length don't match!, wdata2[%d].v.len=%d, rdata2[%d].v.len=%d\n",__LINE__,(int)i,(int)wdata2[i].v.len,(int)i,(int)rdata2[i].v.len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata2[i].v.len != rdata2[i].v.len) { + TestErrPrintf("%d: VL data length don't match!, wdata2[%d].v.len=%d, rdata2[%d].v.len=%d\n", + __LINE__, (int)i, (int)wdata2[i].v.len, (int)i, (int)rdata2[i].v.len); continue; } /* end if */ - for(t1=(s2 *)(wdata2[i].v.p), t2=(s2 *)(rdata2[i].v.p), j=0; j<rdata2[i].v.len; j++, t1++, t2++) { - if(HDstrcmp(t1->string, t2->string)) { - TestErrPrintf("VL data values don't match!, t1->string=%s, t2->string=%s\n",t1->string, t2->string); - continue; - } /* end if */ - if(t1->color != t2->color) { - TestErrPrintf("VL data values don't match!, t1->color=%d, t2->color=%d\n",t1->color, t2->color); - continue; - } /* end if */ - } /* end for */ - } /* end for */ + for (t1 = (s2 *)(wdata2[i].v.p), t2 = (s2 *)(rdata2[i].v.p), j = 0; j < rdata2[i].v.len; + j++, t1++, t2++) { + if (HDstrcmp(t1->string, t2->string)) { + TestErrPrintf("VL data values don't match!, t1->string=%s, t2->string=%s\n", t1->string, + t2->string); + continue; + } /* end if */ + if (t1->color != t2->color) { + TestErrPrintf("VL data values don't match!, t1->color=%d, t2->color=%d\n", t1->color, + t2->color); + continue; + } /* end if */ + } /* end for */ + } /* end for */ /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata2); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata2); CHECK(ret, FAIL, "H5Treclaim"); /* Reclaim the VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata2); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, rdata2); CHECK(ret, FAIL, "H5Treclaim"); ret = H5Dclose(dset2); @@ -1458,36 +1485,36 @@ test_vltypes_compound_vlstr(void) static void test_vltypes_compound_vlen_atomic(void) { - typedef struct { /* Struct that the VL sequences are composed of */ - int i; + typedef struct { /* Struct that the VL sequences are composed of */ + int i; float f; hvl_t v; } s1; - s1 wdata[SPACE1_DIM1]; /* Information to write */ - s1 rdata[SPACE1_DIM1]; /* Information read in */ - s1 fill; /* Fill value */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hid_t dcpl_pid; /* Dataset creation property list ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - herr_t ret; /* Generic return value */ + s1 wdata[SPACE1_DIM1]; /* Information to write */ + s1 rdata[SPACE1_DIM1]; /* Information read in */ + s1 fill; /* Fill value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hid_t dcpl_pid; /* Dataset creation property list ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Compound Datatypes with VL Atomic Datatype Component Functionality\n")); /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { - wdata[i].i = (int)(i * 10); - wdata[i].f = (float)(i * 20) / 3.0F; - wdata[i].v.p = HDmalloc((i + 1)*sizeof(unsigned int)); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].i = (int)(i * 10); + wdata[i].f = (float)(i * 20) / 3.0F; + wdata[i].v.p = HDmalloc((i + 1) * sizeof(unsigned int)); wdata[i].v.len = i + 1; - for(j = 0; j < (i + 1); j++) + for (j = 0; j < (i + 1); j++) ((unsigned int *)wdata[i].v.p)[j] = i * 10 + j; } /* end for */ @@ -1500,7 +1527,7 @@ test_vltypes_compound_vlen_atomic(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a VL datatype to refer to */ - tid1 = H5Tvlen_create (H5T_NATIVE_UINT); + tid1 = H5Tvlen_create(H5T_NATIVE_UINT); CHECK(tid1, FAIL, "H5Tvlen_create"); /* Create the base compound type */ @@ -1527,7 +1554,8 @@ test_vltypes_compound_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory will be used */ @@ -1543,29 +1571,34 @@ test_vltypes_compound_vlen_atomic(void) /* Make certain the correct amount of memory has been used */ /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ - VERIFY(mem_used,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(unsigned int),"H5Dread"); + VERIFY(mem_used, ((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(unsigned int), "H5Dread"); /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata[i].i!=rdata[i].i) { - TestErrPrintf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n",(int)i,(int)wdata[i].i,(int)i,(int)rdata[i].i); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].i != rdata[i].i) { + TestErrPrintf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n", (int)i, + (int)wdata[i].i, (int)i, (int)rdata[i].i); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(wdata[i].f,rdata[i].f)) { - TestErrPrintf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n",(int)i,(double)wdata[i].f,(int)i,(double)rdata[i].f); + if (!H5_FLT_ABS_EQUAL(wdata[i].f, rdata[i].f)) { + TestErrPrintf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n", (int)i, + (double)wdata[i].f, (int)i, (double)rdata[i].f); continue; } /* end if */ - if(wdata[i].v.len!=rdata[i].v.len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n",__LINE__,(int)i,(int)wdata[i].v.len,(int)i,(int)rdata[i].v.len); + if (wdata[i].v.len != rdata[i].v.len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n", + __LINE__, (int)i, (int)wdata[i].v.len, (int)i, (int)rdata[i].v.len); continue; } /* end if */ - for(j=0; j<rdata[i].v.len; j++) { - if( ((unsigned int *)wdata[i].v.p)[j] != ((unsigned int *)rdata[i].v.p)[j] ) { - TestErrPrintf("VL data values don't match!, wdata[%d].v.p[%d]=%d, rdata[%d].v.p[%d]=%d\n",(int)i,(int)j, (int)((unsigned int *)wdata[i].v.p)[j], (int)i,(int)j, (int)((unsigned int *)rdata[i].v.p)[j]); + for (j = 0; j < rdata[i].v.len; j++) { + if (((unsigned int *)wdata[i].v.p)[j] != ((unsigned int *)rdata[i].v.p)[j]) { + TestErrPrintf("VL data values don't match!, wdata[%d].v.p[%d]=%d, rdata[%d].v.p[%d]=%d\n", + (int)i, (int)j, (int)((unsigned int *)wdata[i].v.p)[j], (int)i, (int)j, + (int)((unsigned int *)rdata[i].v.p)[j]); continue; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim the VL data */ ret = H5Treclaim(tid2, sid1, xfer_pid, rdata); @@ -1599,9 +1632,13 @@ test_vltypes_compound_vlen_atomic(void) CHECK(ret, FAIL, "H5Dread"); /* Check data read in */ - for(i = 0; i < SPACE1_DIM1; i++) - if(rdata[i].i != 0 || !H5_FLT_ABS_EQUAL(rdata[i].f, 0.0F) || rdata[i].v.len != 0 || rdata[i].v.p != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d].i=%d, rdata[%d].f=%f, rdata[%d].v.len=%u, rdata[%d].v.p=%p\n",(int)i,rdata[i].i,(int)i,(double)rdata[i].f,(int)i,(unsigned)rdata[i].v.len,(int)i,rdata[i].v.p); + for (i = 0; i < SPACE1_DIM1; i++) + if (rdata[i].i != 0 || !H5_FLT_ABS_EQUAL(rdata[i].f, 0.0F) || rdata[i].v.len != 0 || + rdata[i].v.p != NULL) + TestErrPrintf( + "VL doesn't match!, rdata[%d].i=%d, rdata[%d].f=%f, rdata[%d].v.len=%u, rdata[%d].v.p=%p\n", + (int)i, rdata[i].i, (int)i, (double)rdata[i].f, (int)i, (unsigned)rdata[i].v.len, (int)i, + rdata[i].v.p); /* Write dataset to disk */ ret = H5Dwrite(dataset, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); @@ -1612,29 +1649,34 @@ test_vltypes_compound_vlen_atomic(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < SPACE1_DIM1; i++) { - if(wdata[i].i != rdata[i].i) { - TestErrPrintf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n",(int)i,(int)wdata[i].i,(int)i,(int)rdata[i].i); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].i != rdata[i].i) { + TestErrPrintf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n", (int)i, + (int)wdata[i].i, (int)i, (int)rdata[i].i); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(wdata[i].f,rdata[i].f)) { - TestErrPrintf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n",(int)i,(double)wdata[i].f,(int)i,(double)rdata[i].f); + if (!H5_FLT_ABS_EQUAL(wdata[i].f, rdata[i].f)) { + TestErrPrintf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n", (int)i, + (double)wdata[i].f, (int)i, (double)rdata[i].f); continue; } /* end if */ - if(wdata[i].v.len!=rdata[i].v.len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n",__LINE__,(int)i,(int)wdata[i].v.len,(int)i,(int)rdata[i].v.len); + if (wdata[i].v.len != rdata[i].v.len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n", + __LINE__, (int)i, (int)wdata[i].v.len, (int)i, (int)rdata[i].v.len); continue; } /* end if */ - for(j=0; j<rdata[i].v.len; j++) { - if( ((unsigned int *)wdata[i].v.p)[j] != ((unsigned int *)rdata[i].v.p)[j] ) { - TestErrPrintf("VL data values don't match!, wdata[%d].v.p[%d]=%d, rdata[%d].v.p[%d]=%d\n",(int)i,(int)j, (int)((unsigned int *)wdata[i].v.p)[j], (int)i,(int)j, (int)((unsigned int *)rdata[i].v.p)[j]); + for (j = 0; j < rdata[i].v.len; j++) { + if (((unsigned int *)wdata[i].v.p)[j] != ((unsigned int *)rdata[i].v.p)[j]) { + TestErrPrintf("VL data values don't match!, wdata[%d].v.p[%d]=%d, rdata[%d].v.p[%d]=%d\n", + (int)i, (int)j, (int)((unsigned int *)wdata[i].v.p)[j], (int)i, (int)j, + (int)((unsigned int *)rdata[i].v.p)[j]); continue; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim the VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -1642,7 +1684,7 @@ test_vltypes_compound_vlen_atomic(void) CHECK(ret, FAIL, "H5Dclose"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close datatype */ @@ -1678,34 +1720,35 @@ test_vltypes_compound_vlen_atomic(void) static void rewrite_vltypes_compound_vlen_atomic(void) { - typedef struct { /* Struct that the VL sequences are composed of */ - int i; + typedef struct { /* Struct that the VL sequences are composed of */ + int i; float f; hvl_t v; } s1; - s1 wdata[SPACE1_DIM1]; /* Information to write */ - s1 rdata[SPACE1_DIM1]; /* Information read in */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - unsigned increment=4; - herr_t ret; /* Generic return value */ + s1 wdata[SPACE1_DIM1]; /* Information to write */ + s1 rdata[SPACE1_DIM1]; /* Information read in */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + unsigned increment = 4; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ - MESSAGE(5, ("Checking memory leak for compound datatype with VL Atomic Datatype Component Functionality\n")); + MESSAGE(5, + ("Checking memory leak for compound datatype with VL Atomic Datatype Component Functionality\n")); /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { - wdata[i].i = (int)(i * 40); - wdata[i].f = (float)(i * 50) / 3.0F; - wdata[i].v.p = HDmalloc((i + increment) * sizeof(unsigned int)); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].i = (int)(i * 40); + wdata[i].f = (float)(i * 50) / 3.0F; + wdata[i].v.p = HDmalloc((i + increment) * sizeof(unsigned int)); wdata[i].v.len = i + increment; - for(j = 0; j < (i + increment); j++) + for (j = 0; j < (i + increment); j++) ((unsigned int *)wdata[i].v.p)[j] = i * 60 + j; } /* end for */ @@ -1745,7 +1788,8 @@ rewrite_vltypes_compound_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory will be used */ @@ -1753,47 +1797,52 @@ rewrite_vltypes_compound_vlen_atomic(void) CHECK(ret, FAIL, "H5Dvlen_get_buf_size"); /* 22 elements allocated = 4+5+6+7 elements for each array position */ - VERIFY(size, 22*sizeof(unsigned int),"H5Dvlen_get_buf_size"); + VERIFY(size, 22 * sizeof(unsigned int), "H5Dvlen_get_buf_size"); /* Read dataset from disk */ - ret=H5Dread(dataset,tid2,H5S_ALL,H5S_ALL,xfer_pid,rdata); + ret = H5Dread(dataset, tid2, H5S_ALL, H5S_ALL, xfer_pid, rdata); CHECK(ret, FAIL, "H5Dread"); /* Make certain the correct amount of memory has been used */ /* 22 elements allocated = 4+5+6+7 elements for each array position */ - VERIFY(mem_used,22*sizeof(unsigned int),"H5Dread"); + VERIFY(mem_used, 22 * sizeof(unsigned int), "H5Dread"); /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata[i].i!=rdata[i].i) { - TestErrPrintf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n",(int)i,(int)wdata[i].i,(int)i,(int)rdata[i].i); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].i != rdata[i].i) { + TestErrPrintf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n", (int)i, + (int)wdata[i].i, (int)i, (int)rdata[i].i); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(wdata[i].f,rdata[i].f)) { - TestErrPrintf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n",(int)i,(double)wdata[i].f,(int)i,(double)rdata[i].f); + if (!H5_FLT_ABS_EQUAL(wdata[i].f, rdata[i].f)) { + TestErrPrintf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n", (int)i, + (double)wdata[i].f, (int)i, (double)rdata[i].f); continue; } /* end if */ - if(wdata[i].v.len!=rdata[i].v.len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n",__LINE__,(int)i,(int)wdata[i].v.len,(int)i,(int)rdata[i].v.len); + if (wdata[i].v.len != rdata[i].v.len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n", + __LINE__, (int)i, (int)wdata[i].v.len, (int)i, (int)rdata[i].v.len); continue; } /* end if */ - for(j=0; j<rdata[i].v.len; j++) { - if( ((unsigned int *)wdata[i].v.p)[j] != ((unsigned int *)rdata[i].v.p)[j] ) { - TestErrPrintf("VL data values don't match!, wdata[%d].v.p[%d]=%d, rdata[%d].v.p[%d]=%d\n",(int)i,(int)j, (int)((unsigned int *)wdata[i].v.p)[j], (int)i,(int)j, (int)((unsigned int *)rdata[i].v.p)[j]); + for (j = 0; j < rdata[i].v.len; j++) { + if (((unsigned int *)wdata[i].v.p)[j] != ((unsigned int *)rdata[i].v.p)[j]) { + TestErrPrintf("VL data values don't match!, wdata[%d].v.p[%d]=%d, rdata[%d].v.p[%d]=%d\n", + (int)i, (int)j, (int)((unsigned int *)wdata[i].v.p)[j], (int)i, (int)j, + (int)((unsigned int *)rdata[i].v.p)[j]); continue; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim the VL data */ - ret=H5Treclaim(tid2,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid2, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -1828,18 +1877,19 @@ rewrite_vltypes_compound_vlen_atomic(void) ** Tests VL datatype with VL datatypes of atomic datatypes. ** ****************************************************************/ -static size_t vlen_size_func(unsigned long n) +static size_t +vlen_size_func(unsigned long n) { - size_t u=1; - size_t tmp=1; - size_t result=1; + size_t u = 1; + size_t tmp = 1; + size_t result = 1; - while(u<n) { + while (u < n) { u++; - tmp+=u; - result+=tmp; + tmp += u; + result += tmp; } - return(result); + return (result); } /**************************************************************** @@ -1851,42 +1901,42 @@ static size_t vlen_size_func(unsigned long n) static void test_vltypes_vlen_vlen_atomic(void) { - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t rdata[SPACE1_DIM1]; /* Information read in */ - hvl_t *t1, *t2; /* Temporary pointer to VL information */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j,k; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t rdata[SPACE1_DIM1]; /* Information read in */ + hvl_t * t1, *t2; /* Temporary pointer to VL information */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j, k; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing VL Datatypes with VL Atomic Datatype Component Functionality\n")); /* Allocate and initialize VL data to write */ - for(i=0; i<SPACE1_DIM1; i++) { - wdata[i].p=HDmalloc((i+1)*sizeof(hvl_t)); - if(wdata[i].p==NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u\n",i); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].p = HDmalloc((i + 1) * sizeof(hvl_t)); + if (wdata[i].p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u\n", i); return; } /* end if */ - wdata[i].len=i+1; - for(t1=(hvl_t *)(wdata[i].p),j=0; j<(i+1); j++, t1++) { - t1->p=HDmalloc((j+1)*sizeof(unsigned int)); - if(t1->p==NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + wdata[i].len = i + 1; + for (t1 = (hvl_t *)(wdata[i].p), j = 0; j < (i + 1); j++, t1++) { + t1->p = HDmalloc((j + 1) * sizeof(unsigned int)); + if (t1->p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); return; } /* end if */ - t1->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)t1->p)[k]=i*100+j*10+k; + t1->len = j + 1; + for (k = 0; k < (j + 1); k++) + ((unsigned int *)t1->p)[k] = i * 100 + j * 10 + k; } /* end for */ - } /* end for */ + } /* end for */ /* Create file */ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1897,11 +1947,11 @@ test_vltypes_vlen_vlen_atomic(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a VL datatype to refer to */ - tid1 = H5Tvlen_create (H5T_NATIVE_UINT); + tid1 = H5Tvlen_create(H5T_NATIVE_UINT); CHECK(tid1, FAIL, "H5Tvlen_create"); /* Create the base VL type */ - tid2 = H5Tvlen_create (tid1); + tid2 = H5Tvlen_create(tid1); CHECK(tid2, FAIL, "H5Tvlen_create"); /* Create a dataset */ @@ -1956,7 +2006,8 @@ test_vltypes_vlen_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory was used */ @@ -1965,7 +2016,10 @@ test_vltypes_vlen_vlen_atomic(void) /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */ /* 20 unsigned int elements allocated = 1 + 3 + 6 + 10 elements */ - VERIFY(size, (hsize_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), "H5Dvlen_get_buf_size"); + VERIFY(size, + (hsize_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), + "H5Dvlen_get_buf_size"); /* Read dataset from disk */ ret = H5Dread(dataset, tid2, H5S_ALL, H5S_ALL, xfer_pid, rdata); @@ -1974,37 +2028,43 @@ test_vltypes_vlen_vlen_atomic(void) /* Make certain the correct amount of memory has been used */ /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */ /* 20 unsigned int elements allocated = 1 + 3 + 6 + 10 elements */ - VERIFY(mem_used, (size_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), "H5Dread"); + VERIFY(mem_used, + (size_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), + "H5Dread"); /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata[i].len!=rdata[i].len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",__LINE__,(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].len != rdata[i].len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n", __LINE__, + (int)i, (int)wdata[i].len, (int)i, (int)rdata[i].len); continue; } /* end if */ - for(t1=(hvl_t *)wdata[i].p, t2=(hvl_t *)(rdata[i].p), j=0; j<rdata[i].len; j++, t1++, t2++) { - if(t1->len!=t2->len) { - TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + for (t1 = (hvl_t *)wdata[i].p, t2 = (hvl_t *)(rdata[i].p), j = 0; j < rdata[i].len; j++, t1++, t2++) { + if (t1->len != t2->len) { + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n", + __LINE__, (int)i, (int)j, (int)t1->len, (int)t2->len); continue; } /* end if */ - for(k=0; k<t2->len; k++) { - if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + for (k = 0; k < t2->len; k++) { + if (((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k]) { + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n", (int)k, + (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim all the (nested) VL data */ - ret=H5Treclaim(tid2,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid2, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -2042,42 +2102,42 @@ test_vltypes_vlen_vlen_atomic(void) static void rewrite_longer_vltypes_vlen_vlen_atomic(void) { - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t rdata[SPACE1_DIM1]; /* Information read in */ - hvl_t *t1, *t2; /* Temporary pointer to VL information */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid2; /* Datatype IDs */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j,k; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - unsigned increment=1; - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t rdata[SPACE1_DIM1]; /* Information read in */ + hvl_t * t1, *t2; /* Temporary pointer to VL information */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid2; /* Datatype IDs */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j, k; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + unsigned increment = 1; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Check memory leak for VL Datatypes with VL Atomic Datatype Component Functionality\n")); /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { + for (i = 0; i < SPACE1_DIM1; i++) { wdata[i].p = HDmalloc((i + increment) * sizeof(hvl_t)); - if(wdata[i].p == NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u\n",i); + if (wdata[i].p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u\n", i); return; } /* end if */ wdata[i].len = i + increment; - for(t1 = (hvl_t *)(wdata[i].p), j = 0; j < (i + increment); j++, t1++) { + for (t1 = (hvl_t *)(wdata[i].p), j = 0; j < (i + increment); j++, t1++) { t1->p = HDmalloc((j + 1) * sizeof(unsigned int)); - if(t1->p == NULL) { + if (t1->p == NULL) { TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); return; } /* end if */ t1->len = j + 1; - for(k = 0; k < (j + 1); k++) + for (k = 0; k < (j + 1); k++) ((unsigned int *)t1->p)[k] = i * 1000 + j * 100 + k * 10; } /* end for */ - } /* end for */ + } /* end for */ /* Open file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); @@ -2115,7 +2175,6 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open the file for data checking */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -2136,7 +2195,8 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory was used */ @@ -2157,34 +2217,38 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void) /*VERIFY(mem_used,18*sizeof(hvl_t)+52*sizeof(unsigned int),"H5Dread");*/ /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata[i].len!=rdata[i].len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",__LINE__,(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].len != rdata[i].len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n", __LINE__, + (int)i, (int)wdata[i].len, (int)i, (int)rdata[i].len); continue; } /* end if */ - for(t1=(hvl_t *)(wdata[i].p), t2=(hvl_t *)(rdata[i].p), j=0; j<rdata[i].len; j++, t1++, t2++) { - if(t1->len!=t2->len) { - TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + for (t1 = (hvl_t *)(wdata[i].p), t2 = (hvl_t *)(rdata[i].p), j = 0; j < rdata[i].len; + j++, t1++, t2++) { + if (t1->len != t2->len) { + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n", + __LINE__, (int)i, (int)j, (int)t1->len, (int)t2->len); continue; } /* end if */ - for(k=0; k<t2->len; k++) { - if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + for (k = 0; k < t2->len; k++) { + if (((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k]) { + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n", (int)k, + (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim all the (nested) VL data */ - ret=H5Treclaim(tid2,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid2, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -2218,42 +2282,42 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void) static void rewrite_shorter_vltypes_vlen_vlen_atomic(void) { - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t rdata[SPACE1_DIM1]; /* Information read in */ - hvl_t *t1, *t2; /* Temporary pointer to VL information */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid2; /* Datatype IDs */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j,k; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - unsigned increment=1; - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t rdata[SPACE1_DIM1]; /* Information read in */ + hvl_t * t1, *t2; /* Temporary pointer to VL information */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid2; /* Datatype IDs */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j, k; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + unsigned increment = 1; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Check memory leak for VL Datatypes with VL Atomic Datatype Component Functionality\n")); /* Allocate and initialize VL data to write */ - for(i=0; i<SPACE1_DIM1; i++) { - wdata[i].p=HDmalloc((i+increment)*sizeof(hvl_t)); - if(wdata[i].p==NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u\n",i); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].p = HDmalloc((i + increment) * sizeof(hvl_t)); + if (wdata[i].p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u\n", i); return; } /* end if */ - wdata[i].len=i+increment; - for(t1=(hvl_t *)(wdata[i].p),j=0; j<(i+increment); j++, t1++) { - t1->p=HDmalloc((j+1)*sizeof(unsigned int)); - if(t1->p==NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + wdata[i].len = i + increment; + for (t1 = (hvl_t *)(wdata[i].p), j = 0; j < (i + increment); j++, t1++) { + t1->p = HDmalloc((j + 1) * sizeof(unsigned int)); + if (t1->p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); return; } /* end if */ - t1->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)t1->p)[k]=i*100000+j*1000+k*10; + t1->len = j + 1; + for (k = 0; k < (j + 1); k++) + ((unsigned int *)t1->p)[k] = i * 100000 + j * 1000 + k * 10; } /* end for */ - } /* end for */ + } /* end for */ /* Open file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); @@ -2291,7 +2355,6 @@ rewrite_shorter_vltypes_vlen_vlen_atomic(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open the file for data checking */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -2312,7 +2375,8 @@ rewrite_shorter_vltypes_vlen_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory was used */ @@ -2321,46 +2385,56 @@ rewrite_shorter_vltypes_vlen_vlen_atomic(void) /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */ /* 20 unsigned int elements allocated = 1 + 3 + 6 + 10 elements */ - VERIFY(size, (hsize_t)(((SPACE1_DIM1*(SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), "H5Dvlen_get_buf_size"); + VERIFY(size, + (hsize_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), + "H5Dvlen_get_buf_size"); /* Read dataset from disk */ - ret=H5Dread(dataset,tid2,H5S_ALL,H5S_ALL,xfer_pid,rdata); + ret = H5Dread(dataset, tid2, H5S_ALL, H5S_ALL, xfer_pid, rdata); CHECK(ret, FAIL, "H5Dread"); /* Make certain the correct amount of memory has been used */ /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */ /* 20 unsigned int elements allocated = 1 + 3 + 6 + 10 elements */ - VERIFY(mem_used, (size_t)(((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(hvl_t)+vlen_size_func((unsigned long)SPACE1_DIM1)*sizeof(unsigned int)),"H5Dread"); + VERIFY(mem_used, + (size_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), + "H5Dread"); /* Compare data read in */ - for(i=0; i<SPACE1_DIM1; i++) { - if(wdata[i].len!=rdata[i].len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",__LINE__,(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].len != rdata[i].len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n", __LINE__, + (int)i, (int)wdata[i].len, (int)i, (int)rdata[i].len); continue; } /* end if */ - for(t1=(hvl_t *)(wdata[i].p), t2=(hvl_t *)(rdata[i].p), j=0; j<rdata[i].len; j++, t1++, t2++) { - if(t1->len!=t2->len) { - TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + for (t1 = (hvl_t *)(wdata[i].p), t2 = (hvl_t *)(rdata[i].p), j = 0; j < rdata[i].len; + j++, t1++, t2++) { + if (t1->len != t2->len) { + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n", + __LINE__, (int)i, (int)j, (int)t1->len, (int)t2->len); continue; } /* end if */ - for(k=0; k<t2->len; k++) { - if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + for (k = 0; k < t2->len; k++) { + if (((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k]) { + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n", (int)k, + (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim all the (nested) VL data */ - ret=H5Treclaim(tid2,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid2, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -2396,52 +2470,55 @@ static void test_vltypes_fill_value(void) { typedef struct dtype1_struct { - unsigned int gui; - unsigned int pgui; - const char *str_id; - const char *str_name; - const char *str_desc; - const char *str_orig; - const char *str_stat; - unsigned int ver; - double val; - double ma; - double mi; - const char *str_form; - const char *str_unit; + unsigned int gui; + unsigned int pgui; + const char * str_id; + const char * str_name; + const char * str_desc; + const char * str_orig; + const char * str_stat; + unsigned int ver; + double val; + double ma; + double mi; + const char * str_form; + const char * str_unit; } dtype1_struct; - herr_t ret; - hid_t file_id; - hid_t dtype1_id = -1; - hid_t str_id = -1; - hid_t small_dspace_id; /* Dataspace ID for small datasets */ - hid_t large_dspace_id; /* Dataspace ID for large datasets */ - hid_t small_select_dspace_id; /* Dataspace ID for selection in small datasets */ - hid_t large_select_dspace_id; /* Dataspace ID for selection in large datasets */ - hid_t dset_dspace_id; /* Dataspace ID for a particular dataset */ - hid_t dset_select_dspace_id; /* Dataspace ID for selection in a particular dataset */ - hid_t scalar_dspace_id; /* Dataspace ID for scalar dataspace */ - hid_t single_dspace_id; /* Dataspace ID for single element selection */ - hsize_t single_offset[] = {2}; /* Offset of single element selection */ - hsize_t single_block[] = {1}; /* Block size of single element selection */ - hsize_t select_offset[] = {0}; /* Offset of non-contiguous element selection */ - hsize_t select_stride[] = {2}; /* Stride size of non-contiguous element selection */ - hsize_t small_select_count[] = {SPACE4_DIM_SMALL / 2}; /* Count of small non-contiguous element selection */ - hsize_t large_select_count[] = {SPACE4_DIM_LARGE / 2}; /* Count of large non-contiguous element selection */ - hsize_t select_block[] = {1}; /* Block size of non-contiguous element selection */ - hid_t dcpl_id, xfer_pid; - hid_t dset_id; - hsize_t small_dims[] = {SPACE4_DIM_SMALL}; - hsize_t large_dims[] = {SPACE4_DIM_LARGE}; - size_t dset_elmts; /* Number of elements in a particular dataset */ - const dtype1_struct fill1 = {1, 2, "foobar", "", NULL, "\0", "dead", 3, 4.0F, 100.0F, 1.0F, "liquid", "meter"}; + herr_t ret; + hid_t file_id; + hid_t dtype1_id = -1; + hid_t str_id = -1; + hid_t small_dspace_id; /* Dataspace ID for small datasets */ + hid_t large_dspace_id; /* Dataspace ID for large datasets */ + hid_t small_select_dspace_id; /* Dataspace ID for selection in small datasets */ + hid_t large_select_dspace_id; /* Dataspace ID for selection in large datasets */ + hid_t dset_dspace_id; /* Dataspace ID for a particular dataset */ + hid_t dset_select_dspace_id; /* Dataspace ID for selection in a particular dataset */ + hid_t scalar_dspace_id; /* Dataspace ID for scalar dataspace */ + hid_t single_dspace_id; /* Dataspace ID for single element selection */ + hsize_t single_offset[] = {2}; /* Offset of single element selection */ + hsize_t single_block[] = {1}; /* Block size of single element selection */ + hsize_t select_offset[] = {0}; /* Offset of non-contiguous element selection */ + hsize_t select_stride[] = {2}; /* Stride size of non-contiguous element selection */ + hsize_t small_select_count[] = {SPACE4_DIM_SMALL / + 2}; /* Count of small non-contiguous element selection */ + hsize_t large_select_count[] = {SPACE4_DIM_LARGE / + 2}; /* Count of large non-contiguous element selection */ + hsize_t select_block[] = {1}; /* Block size of non-contiguous element selection */ + hid_t dcpl_id, xfer_pid; + hid_t dset_id; + hsize_t small_dims[] = {SPACE4_DIM_SMALL}; + hsize_t large_dims[] = {SPACE4_DIM_LARGE}; + size_t dset_elmts; /* Number of elements in a particular dataset */ + const dtype1_struct fill1 = {1, 2, "foobar", "", NULL, "\0", "dead", + 3, 4.0F, 100.0F, 1.0F, "liquid", "meter"}; const dtype1_struct wdata = {3, 4, "", NULL, "\0", "foo", "two", 6, 8.0F, 200.0F, 2.0F, "solid", "yard"}; - dtype1_struct *rbuf = NULL; /* Buffer for reading data */ - size_t mem_used = 0; /* Memory used during allocation */ - H5D_layout_t layout; /* Dataset storage layout */ - char dset_name1[64], dset_name2[64]; /* Dataset names */ - unsigned i; + dtype1_struct * rbuf = NULL; /* Buffer for reading data */ + size_t mem_used = 0; /* Memory used during allocation */ + H5D_layout_t layout; /* Dataset storage layout */ + char dset_name1[64], dset_name2[64]; /* Dataset names */ + unsigned i; /* Output message about test being performed */ MESSAGE(5, ("Check fill value for VL data\n")); @@ -2449,62 +2526,60 @@ test_vltypes_fill_value(void) /* Create a string datatype */ str_id = H5Tcopy(H5T_C_S1); CHECK(str_id, FAIL, "H5Tcopy"); - ret = H5Tset_size(str_id,H5T_VARIABLE); + ret = H5Tset_size(str_id, H5T_VARIABLE); CHECK(ret, FAIL, "H5Tset_size"); /* Create a compound data type */ dtype1_id = H5Tcreate(H5T_COMPOUND, sizeof(struct dtype1_struct)); CHECK(dtype1_id, FAIL, "H5Tcreate"); - ret = H5Tinsert(dtype1_id,"guid",HOFFSET(struct dtype1_struct,gui),H5T_NATIVE_UINT); + ret = H5Tinsert(dtype1_id, "guid", HOFFSET(struct dtype1_struct, gui), H5T_NATIVE_UINT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"pguid",HOFFSET(struct dtype1_struct,pgui),H5T_NATIVE_UINT); + ret = H5Tinsert(dtype1_id, "pguid", HOFFSET(struct dtype1_struct, pgui), H5T_NATIVE_UINT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_id",HOFFSET(dtype1_struct,str_id),str_id); + ret = H5Tinsert(dtype1_id, "str_id", HOFFSET(dtype1_struct, str_id), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_name",HOFFSET(dtype1_struct,str_name),str_id); + ret = H5Tinsert(dtype1_id, "str_name", HOFFSET(dtype1_struct, str_name), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_desc",HOFFSET(dtype1_struct,str_desc),str_id); + ret = H5Tinsert(dtype1_id, "str_desc", HOFFSET(dtype1_struct, str_desc), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_orig",HOFFSET(dtype1_struct,str_orig),str_id); + ret = H5Tinsert(dtype1_id, "str_orig", HOFFSET(dtype1_struct, str_orig), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_stat",HOFFSET(dtype1_struct,str_stat),str_id); + ret = H5Tinsert(dtype1_id, "str_stat", HOFFSET(dtype1_struct, str_stat), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"ver",HOFFSET(struct dtype1_struct,ver),H5T_NATIVE_UINT); + ret = H5Tinsert(dtype1_id, "ver", HOFFSET(struct dtype1_struct, ver), H5T_NATIVE_UINT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"val",HOFFSET(struct dtype1_struct,val),H5T_NATIVE_DOUBLE); + ret = H5Tinsert(dtype1_id, "val", HOFFSET(struct dtype1_struct, val), H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"ma",HOFFSET(struct dtype1_struct,ma),H5T_NATIVE_DOUBLE); + ret = H5Tinsert(dtype1_id, "ma", HOFFSET(struct dtype1_struct, ma), H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"mi",HOFFSET(struct dtype1_struct,mi),H5T_NATIVE_DOUBLE); + ret = H5Tinsert(dtype1_id, "mi", HOFFSET(struct dtype1_struct, mi), H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_form",HOFFSET(dtype1_struct,str_form),str_id); + ret = H5Tinsert(dtype1_id, "str_form", HOFFSET(dtype1_struct, str_form), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_unit",HOFFSET(dtype1_struct,str_unit),str_id); + ret = H5Tinsert(dtype1_id, "str_unit", HOFFSET(dtype1_struct, str_unit), str_id); CHECK(ret, FAIL, "H5Tinsert"); /* Close string datatype */ ret = H5Tclose(str_id); CHECK(ret, FAIL, "H5Tclose"); - /* Allocate space for the buffer to read data */ rbuf = (dtype1_struct *)HDmalloc(SPACE4_DIM_LARGE * sizeof(dtype1_struct)); CHECK_PTR(rbuf, "HDmalloc"); - /* Create the small & large dataspaces to use */ small_dspace_id = H5Screate_simple(SPACE4_RANK, small_dims, NULL); CHECK(small_dspace_id, FAIL, "H5Screate_simple"); @@ -2516,15 +2591,15 @@ test_vltypes_fill_value(void) small_select_dspace_id = H5Scopy(small_dspace_id); CHECK(small_select_dspace_id, FAIL, "H5Scopy"); - ret = H5Sselect_hyperslab(small_select_dspace_id, H5S_SELECT_SET, - select_offset, select_stride, small_select_count, select_block); + ret = H5Sselect_hyperslab(small_select_dspace_id, H5S_SELECT_SET, select_offset, select_stride, + small_select_count, select_block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); large_select_dspace_id = H5Scopy(large_dspace_id); CHECK(large_select_dspace_id, FAIL, "H5Scopy"); - ret = H5Sselect_hyperslab(large_select_dspace_id, H5S_SELECT_SET, - select_offset, select_stride, large_select_count, select_block); + ret = H5Sselect_hyperslab(large_select_dspace_id, H5S_SELECT_SET, select_offset, select_stride, + large_select_count, select_block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create a scalar dataspace */ @@ -2543,32 +2618,32 @@ test_vltypes_fill_value(void) CHECK(file_id, FAIL, "H5Fcreate"); /* Create datasets with different storage layouts */ - for(layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { - unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ - unsigned test_loop; /* Loop over datasets */ + for (layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { + unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ + unsigned test_loop; /* Loop over datasets */ #ifdef H5_HAVE_FILTER_DEFLATE - if(layout == H5D_CHUNKED) + if (layout == H5D_CHUNKED) compress_loop = 2; else #endif /* H5_HAVE_FILTER_DEFLATE */ compress_loop = 1; /* Loop over dataset operations */ - for(test_loop = 0; test_loop < compress_loop; test_loop++) { - hid_t tmp_dcpl_id; /* Temporary copy of the dataset creation property list */ + for (test_loop = 0; test_loop < compress_loop; test_loop++) { + hid_t tmp_dcpl_id; /* Temporary copy of the dataset creation property list */ /* Make a copy of the dataset creation property list */ tmp_dcpl_id = H5Pcopy(dcpl_id); CHECK(tmp_dcpl_id, FAIL, "H5Pcopy"); /* Layout specific actions */ - switch(layout) { + switch (layout) { case H5D_COMPACT: HDstrcpy(dset_name1, "dataset1-compact"); HDstrcpy(dset_name2, "dataset2-compact"); dset_dspace_id = small_dspace_id; - ret = H5Pset_layout(tmp_dcpl_id, H5D_COMPACT); + ret = H5Pset_layout(tmp_dcpl_id, H5D_COMPACT); CHECK(ret, FAIL, "H5Pset_layout"); break; @@ -2578,29 +2653,27 @@ test_vltypes_fill_value(void) dset_dspace_id = large_dspace_id; break; - case H5D_CHUNKED: - { - hsize_t chunk_dims[1] = {SPACE4_DIM_LARGE / 4}; + case H5D_CHUNKED: { + hsize_t chunk_dims[1] = {SPACE4_DIM_LARGE / 4}; - dset_dspace_id = large_dspace_id; - ret = H5Pset_chunk(tmp_dcpl_id, 1, chunk_dims); - CHECK(ret, FAIL, "H5Pset_chunk"); + dset_dspace_id = large_dspace_id; + ret = H5Pset_chunk(tmp_dcpl_id, 1, chunk_dims); + CHECK(ret, FAIL, "H5Pset_chunk"); #ifdef H5_HAVE_FILTER_DEFLATE - if(test_loop == 1) { - HDstrcpy(dset_name1, "dataset1-chunked-compressed"); - HDstrcpy(dset_name2, "dataset2-chunked-compressed"); - ret = H5Pset_deflate(tmp_dcpl_id, 3); - CHECK(ret, FAIL, "H5Pset_deflate"); - } /* end if */ - else { + if (test_loop == 1) { + HDstrcpy(dset_name1, "dataset1-chunked-compressed"); + HDstrcpy(dset_name2, "dataset2-chunked-compressed"); + ret = H5Pset_deflate(tmp_dcpl_id, 3); + CHECK(ret, FAIL, "H5Pset_deflate"); + } /* end if */ + else { #endif /* H5_HAVE_FILTER_DEFLATE */ - HDstrcpy(dset_name1, "dataset1-chunked"); - HDstrcpy(dset_name2, "dataset2-chunked"); + HDstrcpy(dset_name1, "dataset1-chunked"); + HDstrcpy(dset_name2, "dataset2-chunked"); #ifdef H5_HAVE_FILTER_DEFLATE - } /* end else */ -#endif /* H5_HAVE_FILTER_DEFLATE */ - } - break; + } /* end else */ +#endif /* H5_HAVE_FILTER_DEFLATE */ + } break; case H5D_VIRTUAL: assert(0 && "Invalid layout type!"); @@ -2614,13 +2687,13 @@ test_vltypes_fill_value(void) } /* end switch */ /* Create first data set with default setting - no space is allocated */ - dset_id = H5Dcreate2(file_id, dset_name1, dtype1_id, dset_dspace_id, H5P_DEFAULT, tmp_dcpl_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, dset_name1, dtype1_id, dset_dspace_id, H5P_DEFAULT, tmp_dcpl_id, + H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dcreate2"); ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); - /* Create a second data set with space allocated and fill value written */ ret = H5Pset_fill_time(tmp_dcpl_id, H5D_FILL_TIME_IFSET); CHECK(ret, FAIL, "H5Pset_fill_time"); @@ -2628,7 +2701,8 @@ test_vltypes_fill_value(void) ret = H5Pset_alloc_time(tmp_dcpl_id, H5D_ALLOC_TIME_EARLY); CHECK(ret, FAIL, "H5Pset_alloc_time"); - dset_id = H5Dcreate2(file_id, dset_name2, dtype1_id, dset_dspace_id, H5P_DEFAULT, tmp_dcpl_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, dset_name2, dtype1_id, dset_dspace_id, H5P_DEFAULT, tmp_dcpl_id, + H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dcreate2"); ret = H5Dclose(dset_id); @@ -2638,7 +2712,7 @@ test_vltypes_fill_value(void) ret = H5Pclose(tmp_dcpl_id); CHECK(ret, FAIL, "H5Pclose"); } /* end for */ - } /* end for */ + } /* end for */ ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); @@ -2646,12 +2720,12 @@ test_vltypes_fill_value(void) ret = H5Pclose(dcpl_id); CHECK(ret, FAIL, "H5Pclose"); - /* Change to the custom memory allocation routines for reading VL data */ - xfer_pid=H5Pcreate(H5P_DATASET_XFER); + xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret=H5Pset_vlen_mem_manager(xfer_pid,test_vltypes_alloc_custom,&mem_used,test_vltypes_free_custom,&mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Open the file to check data set value */ @@ -2659,41 +2733,41 @@ test_vltypes_fill_value(void) CHECK(file_id, FAIL, "H5Fopen"); /* Read empty datasets with different storage layouts */ - for(layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { - unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ - unsigned test_loop; /* Loop over datasets */ + for (layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { + unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ + unsigned test_loop; /* Loop over datasets */ #ifdef H5_HAVE_FILTER_DEFLATE - if(layout == H5D_CHUNKED) + if (layout == H5D_CHUNKED) compress_loop = 2; else #endif /* H5_HAVE_FILTER_DEFLATE */ compress_loop = 1; /* Loop over dataset operations */ - for(test_loop = 0; test_loop < compress_loop; test_loop++) { + for (test_loop = 0; test_loop < compress_loop; test_loop++) { /* Layout specific actions */ - switch(layout) { + switch (layout) { case H5D_COMPACT: HDstrcpy(dset_name1, "dataset1-compact"); HDstrcpy(dset_name2, "dataset2-compact"); - dset_dspace_id = small_dspace_id; + dset_dspace_id = small_dspace_id; dset_select_dspace_id = small_select_dspace_id; - dset_elmts = SPACE4_DIM_SMALL; + dset_elmts = SPACE4_DIM_SMALL; break; case H5D_CONTIGUOUS: HDstrcpy(dset_name1, "dataset1-contig"); HDstrcpy(dset_name2, "dataset2-contig"); - dset_dspace_id = large_dspace_id; + dset_dspace_id = large_dspace_id; dset_select_dspace_id = large_select_dspace_id; - dset_elmts = SPACE4_DIM_LARGE; + dset_elmts = SPACE4_DIM_LARGE; break; case H5D_CHUNKED: #ifdef H5_HAVE_FILTER_DEFLATE - if(test_loop == 1) { + if (test_loop == 1) { HDstrcpy(dset_name1, "dataset1-chunked-compressed"); HDstrcpy(dset_name2, "dataset2-chunked-compressed"); } /* end if */ @@ -2703,10 +2777,10 @@ test_vltypes_fill_value(void) HDstrcpy(dset_name2, "dataset2-chunked"); #ifdef H5_HAVE_FILTER_DEFLATE } /* end else */ -#endif /* H5_HAVE_FILTER_DEFLATE */ - dset_dspace_id = large_dspace_id; +#endif /* H5_HAVE_FILTER_DEFLATE */ + dset_dspace_id = large_dspace_id; dset_select_dspace_id = large_select_dspace_id; - dset_elmts = SPACE4_DIM_LARGE; + dset_elmts = SPACE4_DIM_LARGE; break; case H5D_VIRTUAL: @@ -2729,18 +2803,15 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { + for (i = 0; i < dset_elmts; i++) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end for */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); @@ -2754,28 +2825,24 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if((i % 2) == select_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { + for (i = 0; i < dset_elmts; i++) { + if ((i % 2) == select_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc - || rbuf[i].str_orig || rbuf[i].str_stat - || rbuf[i].str_form || rbuf[i].str_unit) { + if (rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc || rbuf[i].str_orig || + rbuf[i].str_stat || rbuf[i].str_form || rbuf[i].str_unit) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); @@ -2784,7 +2851,6 @@ test_vltypes_fill_value(void) ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); - /* Open the second data set to check the value of data */ dset_id = H5Dopen2(file_id, dset_name2, H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dopen2"); @@ -2794,18 +2860,15 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + for (i = 0; i < dset_elmts; i++) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end for */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); @@ -2819,28 +2882,24 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if((i % 2) == select_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { + for (i = 0; i < dset_elmts; i++) { + if ((i % 2) == select_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc - || rbuf[i].str_orig || rbuf[i].str_stat - || rbuf[i].str_form || rbuf[i].str_unit) { + if (rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc || rbuf[i].str_orig || + rbuf[i].str_stat || rbuf[i].str_form || rbuf[i].str_unit) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf); @@ -2849,52 +2908,51 @@ test_vltypes_fill_value(void) ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); } /* end for */ - } /* end for */ + } /* end for */ ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); - /* Open the file to check data set value */ file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(file_id, FAIL, "H5Fopen"); /* Write one element & fill values to datasets with different storage layouts */ - for(layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { - unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ - unsigned test_loop; /* Loop over datasets */ + for (layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { + unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ + unsigned test_loop; /* Loop over datasets */ #ifdef H5_HAVE_FILTER_DEFLATE - if(layout == H5D_CHUNKED) + if (layout == H5D_CHUNKED) compress_loop = 2; else #endif /* H5_HAVE_FILTER_DEFLATE */ compress_loop = 1; /* Loop over dataset operations */ - for(test_loop = 0; test_loop < compress_loop; test_loop++) { + for (test_loop = 0; test_loop < compress_loop; test_loop++) { /* Layout specific actions */ - switch(layout) { + switch (layout) { case H5D_COMPACT: HDstrcpy(dset_name1, "dataset1-compact"); HDstrcpy(dset_name2, "dataset2-compact"); - dset_dspace_id = small_dspace_id; + dset_dspace_id = small_dspace_id; dset_select_dspace_id = small_select_dspace_id; - dset_elmts = SPACE4_DIM_SMALL; + dset_elmts = SPACE4_DIM_SMALL; break; case H5D_CONTIGUOUS: HDstrcpy(dset_name1, "dataset1-contig"); HDstrcpy(dset_name2, "dataset2-contig"); - dset_dspace_id = large_dspace_id; + dset_dspace_id = large_dspace_id; dset_select_dspace_id = large_select_dspace_id; - dset_elmts = SPACE4_DIM_LARGE; + dset_elmts = SPACE4_DIM_LARGE; break; case H5D_CHUNKED: #ifdef H5_HAVE_FILTER_DEFLATE - if(test_loop == 1) { + if (test_loop == 1) { HDstrcpy(dset_name1, "dataset1-chunked-compressed"); HDstrcpy(dset_name2, "dataset2-chunked-compressed"); } /* end if */ @@ -2904,10 +2962,10 @@ test_vltypes_fill_value(void) HDstrcpy(dset_name2, "dataset2-chunked"); #ifdef H5_HAVE_FILTER_DEFLATE } /* end else */ -#endif /* H5_HAVE_FILTER_DEFLATE */ - dset_dspace_id = large_dspace_id; +#endif /* H5_HAVE_FILTER_DEFLATE */ + dset_dspace_id = large_dspace_id; dset_select_dspace_id = large_select_dspace_id; - dset_elmts = SPACE4_DIM_LARGE; + dset_elmts = SPACE4_DIM_LARGE; break; case H5D_VIRTUAL: @@ -2926,8 +2984,8 @@ test_vltypes_fill_value(void) CHECK(single_dspace_id, FAIL, "H5Scopy"); /* Set a single element in the dataspace */ - ret = H5Sselect_hyperslab(single_dspace_id, H5S_SELECT_SET, single_offset, - NULL, single_block, NULL); + ret = H5Sselect_hyperslab(single_dspace_id, H5S_SELECT_SET, single_offset, NULL, single_block, + NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Open first data set */ @@ -2942,32 +3000,28 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(i == single_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, wdata.str_id) - || rbuf[i].str_name - || HDstrcmp(rbuf[i].str_desc, wdata.str_desc) - || HDstrcmp(rbuf[i].str_orig, wdata.str_orig) - || HDstrcmp(rbuf[i].str_stat, wdata.str_stat) - || HDstrcmp(rbuf[i].str_form, wdata.str_form) - || HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + for (i = 0; i < dset_elmts; i++) { + if (i == single_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, wdata.str_id) || rbuf[i].str_name || + HDstrcmp(rbuf[i].str_desc, wdata.str_desc) || + HDstrcmp(rbuf[i].str_orig, wdata.str_orig) || + HDstrcmp(rbuf[i].str_stat, wdata.str_stat) || + HDstrcmp(rbuf[i].str_form, wdata.str_form) || + HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig,"\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); @@ -2981,42 +3035,37 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(i == single_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, wdata.str_id) - || rbuf[i].str_name - || HDstrcmp(rbuf[i].str_desc, wdata.str_desc) - || HDstrcmp(rbuf[i].str_orig, wdata.str_orig) - || HDstrcmp(rbuf[i].str_stat, wdata.str_stat) - || HDstrcmp(rbuf[i].str_form, wdata.str_form) - || HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + for (i = 0; i < dset_elmts; i++) { + if (i == single_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, wdata.str_id) || rbuf[i].str_name || + HDstrcmp(rbuf[i].str_desc, wdata.str_desc) || + HDstrcmp(rbuf[i].str_orig, wdata.str_orig) || + HDstrcmp(rbuf[i].str_stat, wdata.str_stat) || + HDstrcmp(rbuf[i].str_form, wdata.str_form) || + HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if((i % 2) == select_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { + if ((i % 2) == select_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc - || rbuf[i].str_orig || rbuf[i].str_stat - || rbuf[i].str_form || rbuf[i].str_unit) { + if (rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc || rbuf[i].str_orig || + rbuf[i].str_stat || rbuf[i].str_form || rbuf[i].str_unit) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end else */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end else */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf); @@ -3025,7 +3074,6 @@ test_vltypes_fill_value(void) ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); - /* Open the second data set to check the value of data */ dset_id = H5Dopen2(file_id, dset_name2, H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dopen2"); @@ -3038,32 +3086,28 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(i == single_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, wdata.str_id) - || rbuf[i].str_name - || HDstrcmp(rbuf[i].str_desc, wdata.str_desc) - || HDstrcmp(rbuf[i].str_orig, wdata.str_orig) - || HDstrcmp(rbuf[i].str_stat, wdata.str_stat) - || HDstrcmp(rbuf[i].str_form, wdata.str_form) - || HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + for (i = 0; i < dset_elmts; i++) { + if (i == single_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, wdata.str_id) || rbuf[i].str_name || + HDstrcmp(rbuf[i].str_desc, wdata.str_desc) || + HDstrcmp(rbuf[i].str_orig, wdata.str_orig) || + HDstrcmp(rbuf[i].str_stat, wdata.str_stat) || + HDstrcmp(rbuf[i].str_form, wdata.str_form) || + HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig,"\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); @@ -3077,42 +3121,37 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(i == single_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, wdata.str_id) - || rbuf[i].str_name - || HDstrcmp(rbuf[i].str_desc, wdata.str_desc) - || HDstrcmp(rbuf[i].str_orig, wdata.str_orig) - || HDstrcmp(rbuf[i].str_stat, wdata.str_stat) - || HDstrcmp(rbuf[i].str_form, wdata.str_form) - || HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + for (i = 0; i < dset_elmts; i++) { + if (i == single_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, wdata.str_id) || rbuf[i].str_name || + HDstrcmp(rbuf[i].str_desc, wdata.str_desc) || + HDstrcmp(rbuf[i].str_orig, wdata.str_orig) || + HDstrcmp(rbuf[i].str_stat, wdata.str_stat) || + HDstrcmp(rbuf[i].str_form, wdata.str_form) || + HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if((i % 2) == select_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { + if ((i % 2) == select_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc - || rbuf[i].str_orig || rbuf[i].str_stat - || rbuf[i].str_form || rbuf[i].str_unit) { + if (rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc || rbuf[i].str_orig || + rbuf[i].str_stat || rbuf[i].str_form || rbuf[i].str_unit) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end else */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end else */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf); @@ -3125,12 +3164,11 @@ test_vltypes_fill_value(void) ret = H5Sclose(single_dspace_id); CHECK(ret, FAIL, "H5Sclose"); } /* end for */ - } /* end for */ + } /* end for */ ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); - /* Clean up rest of IDs */ ret = H5Pclose(xfer_pid); CHECK(ret, FAIL, "H5Pclose"); @@ -3169,23 +3207,22 @@ test_vltypes(void) MESSAGE(5, ("Testing Variable-Length Datatypes\n")); /* These next tests use the same file */ - test_vltypes_dataset_create(); /* Check dataset of VL when fill value - * won't be rewritten to it.*/ - test_vltypes_funcs(); /* Test functions with VL types */ - test_vltypes_vlen_atomic(); /* Test VL atomic datatypes */ - rewrite_vltypes_vlen_atomic(); /* Check VL memory leak */ - test_vltypes_vlen_compound(); /* Test VL compound datatypes */ - rewrite_vltypes_vlen_compound(); /* Check VL memory leak */ - test_vltypes_compound_vlen_atomic(); /* Test compound datatypes with VL atomic components */ - rewrite_vltypes_compound_vlen_atomic();/* Check VL memory leak */ - test_vltypes_vlen_vlen_atomic(); /* Test VL datatype with VL atomic components */ + test_vltypes_dataset_create(); /* Check dataset of VL when fill value + * won't be rewritten to it.*/ + test_vltypes_funcs(); /* Test functions with VL types */ + test_vltypes_vlen_atomic(); /* Test VL atomic datatypes */ + rewrite_vltypes_vlen_atomic(); /* Check VL memory leak */ + test_vltypes_vlen_compound(); /* Test VL compound datatypes */ + rewrite_vltypes_vlen_compound(); /* Check VL memory leak */ + test_vltypes_compound_vlen_atomic(); /* Test compound datatypes with VL atomic components */ + rewrite_vltypes_compound_vlen_atomic(); /* Check VL memory leak */ + test_vltypes_vlen_vlen_atomic(); /* Test VL datatype with VL atomic components */ rewrite_longer_vltypes_vlen_vlen_atomic(); /*overwrite with VL data of longer sequence*/ - rewrite_shorter_vltypes_vlen_vlen_atomic(); /*overwrite with VL data of shorted sequence*/ - test_vltypes_compound_vlen_vlen();/* Test compound datatypes with VL atomic components */ - test_vltypes_compound_vlstr(); /* Test data rewritten of nested VL data */ - test_vltypes_fill_value(); /* Test fill value for VL data */ -} /* test_vltypes() */ - + rewrite_shorter_vltypes_vlen_vlen_atomic(); /*overwrite with VL data of shorted sequence*/ + test_vltypes_compound_vlen_vlen(); /* Test compound datatypes with VL atomic components */ + test_vltypes_compound_vlstr(); /* Test data rewritten of nested VL data */ + test_vltypes_fill_value(); /* Test fill value for VL data */ +} /* test_vltypes() */ /*------------------------------------------------------------------------- * Function: cleanup_vltypes |