diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-10-23 20:40:14 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-10-23 20:40:14 (GMT) |
commit | e40557304fcfc662bb1a445abca516ee4b246d94 (patch) | |
tree | c9f1692443a62e0c481c7c0278e39d7b83d1b419 /test/fillval.c | |
parent | 1062b4f9d7080a3e439df7d3d527aee43f96d085 (diff) | |
download | hdf5-e40557304fcfc662bb1a445abca516ee4b246d94.zip hdf5-e40557304fcfc662bb1a445abca516ee4b246d94.tar.gz hdf5-e40557304fcfc662bb1a445abca516ee4b246d94.tar.bz2 |
[svn-r12803] Description:
Finish new version of the I/O pipeline message, which is much smaller than
the previous version. This version is used with the "use the latest version
of the format" flag.
Closed several memory leaks/overruns (found with valgrind).
Also, lots of compiler & formatting cleanups.
Tested on:
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'test/fillval.c')
-rw-r--r-- | test/fillval.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/test/fillval.c b/test/fillval.c index 3691e38..f0e80cd 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -626,14 +626,16 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, } /* Create dataset */ - if ((fspace=H5Screate_simple(5, cur_size, cur_size))<0) goto error; - if (datatype==H5T_INTEGER && (dset1=H5Dcreate(file, dname, H5T_NATIVE_INT, - fspace, dcpl))<0) goto error; - if (datatype==H5T_COMPOUND && (dset2=H5Dcreate(file, dname, ctype_id, - fspace, dcpl))<0) goto error; + if((fspace = H5Screate_simple(5, cur_size, cur_size)) < 0) + goto error; + if(datatype == H5T_INTEGER && (dset1 = H5Dcreate(file, dname, H5T_NATIVE_INT, fspace, dcpl)) < 0) + goto error; + if(datatype == H5T_COMPOUND && (dset2 = H5Dcreate(file, dname, ctype_id, fspace, dcpl)) < 0) + goto error; /* Read some data and make sure it's the fill value */ - if ((mspace=H5Screate_simple(5, one, NULL))<0) goto error; + if((mspace = H5Screate_simple(5, one, NULL)) < 0) + goto error; for (i=0; i<1000; i++) { for (j=0; j<5; j++) { hs_offset[j] = rand() % cur_size[j]; @@ -689,25 +691,25 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, /* case for atomic datatype */ if(datatype==H5T_INTEGER) { /*check for overflow*/ - assert((nelmts*sizeof(int))==(hsize_t)((size_t)(nelmts*sizeof(int)))); - buf = malloc((size_t)(nelmts*sizeof(int))); - for (u=0; u<nelmts; u++) buf[u] = 9999; + HDassert((nelmts*sizeof(int))==(hsize_t)((size_t)(nelmts*sizeof(int)))); + buf = HDmalloc((size_t)(nelmts * sizeof(int))); + for(u = 0; u < nelmts; u++) + buf[u] = 9999; if (H5Dwrite(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf)<0) goto error; } /* case for compound datatype */ else if(datatype==H5T_COMPOUND) { - assert((nelmts*sizeof(comp_datatype))== - (hsize_t)((size_t)(nelmts*sizeof(comp_datatype)))); - buf_c = (comp_datatype*)calloc((size_t)nelmts,sizeof(comp_datatype)); + HDassert((nelmts*sizeof(comp_datatype))== + (hsize_t)((size_t)(nelmts*sizeof(comp_datatype)))); + buf_c = (comp_datatype*)HDcalloc((size_t)nelmts,sizeof(comp_datatype)); for (u=0; u<nelmts; u++) { buf_c[u].a = (float)1111.11; buf_c[u].x = 2222; buf_c[u].y = 3333.3333; buf_c[u].z = 'd'; } - if (H5Dwrite(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, - buf_c)<0) goto error; + if (H5Dwrite(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, buf_c)<0) goto error; } /* Check if space is allocated */ @@ -721,24 +723,25 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, printf(" Got %d\n", allocation); goto error; } - free(buf); + HDfree(buf); buf = NULL; H5Sclose(mspace); /* Read some data and make sure it's the right value */ - if ((mspace=H5Screate_simple(5, one, NULL))<0) goto error; - for (i=0; i<1000; i++) { - for (j=0, odd=0; j<5; j++) { + if((mspace = H5Screate_simple(5, one, NULL)) < 0) + goto error; + for(i = 0; i < 1000; i++) { + for(j = 0, odd = 0; j < 5; j++) { hs_offset[j] = rand() % cur_size[j]; odd += (int)(hs_offset[j]%2); - } - if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, - one, NULL)<0) goto error; + } /* end for */ + if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + goto error; /* case for atomic datatype */ - if (datatype==H5T_INTEGER) { - if (H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, - &val_rd)<0) goto error; + if(datatype==H5T_INTEGER) { + if(H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, &val_rd) < 0) + goto error; if(fill_time == H5D_FILL_TIME_ALLOC) { should_be = odd ? fillval : 9999; if (val_rd!=should_be) { @@ -769,9 +772,9 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, } } /* end for datatype==H5T_INTEGER */ /* case for compound datatype */ - else if (datatype==H5T_COMPOUND) { - if (H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, - &rd_c)<0) goto error; + else if(datatype==H5T_COMPOUND) { + if(H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, &rd_c) < 0) + goto error; if(fill_time == H5D_FILL_TIME_ALLOC) { if(odd) { should_be_c.a=fill_c.a; @@ -822,6 +825,10 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, } } /* end for datatype==H5T_COMPOUND */ } + if(datatype == H5T_COMPOUND) { + HDfree(buf_c); + buf_c = NULL; + } /* end if */ if (H5Sclose(mspace)<0) goto error; if (datatype==H5T_INTEGER && H5Dclose(dset1)<0) goto error; |