summaryrefslogtreecommitdiffstats
path: root/test/gheap.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-08-20 22:22:40 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-08-20 22:22:40 (GMT)
commit0b00c26b027b2d2afd3112d24573ceb767fc8376 (patch)
tree6dfeabd5453da487c6e6473bd24c82895b4496b5 /test/gheap.c
parent2d7c01d1eb8254c3b5d4977428edcf1c2523bd5e (diff)
downloadhdf5-0b00c26b027b2d2afd3112d24573ceb767fc8376.zip
hdf5-0b00c26b027b2d2afd3112d24573ceb767fc8376.tar.gz
hdf5-0b00c26b027b2d2afd3112d24573ceb767fc8376.tar.bz2
[svn-r19274] Description:
Bring r19272 & 19273 from trunk to 1.8 branch: Close out various resource leaks and usages of uninitialized memory that were flagged by valgrind. [There's still some more valgrind warnings, but it's better now... :-/ ] Also clean up warnings and code formatting. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Mac OS X/32 10.6.4 (amazon) in debug mode Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
Diffstat (limited to 'test/gheap.c')
-rw-r--r--test/gheap.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/test/gheap.c b/test/gheap.c
index b2c9090..2829e34 100644
--- a/test/gheap.c
+++ b/test/gheap.c
@@ -75,24 +75,24 @@ const char *FILENAME[] = {
static int
test_1 (hid_t fapl)
{
- hid_t file=-1;
- H5F_t *f=NULL;
+ hid_t file = -1;
+ H5F_t *f = NULL;
H5HG_t obj[1024];
uint8_t out[1024];
uint8_t in[1024];
int i;
size_t size;
herr_t status;
- int nerrors=0;
+ int nerrors = 0;
char filename[1024];
TESTING("monotonically increasing lengths");
/* Open a clean file */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
- if (NULL==(f=H5I_object(file))) {
+ if(NULL == (f = (H5F_t *)H5I_object(file))) {
H5_FAILED();
puts(" Unable to create file");
goto error;
@@ -103,16 +103,16 @@ test_1 (hid_t fapl)
* a clean file, the addresses allocated for the collections should also
* be monotonically increasing.
*/
- for (i=0; i<1024; i++) {
- size = i+1;
- memset (out, 'A'+i%26, size);
+ for(i = 0; i < 1024; i++) {
+ size = i + 1;
+ HDmemset(out, 'A' + i % 26, size);
H5Eclear2(H5E_DEFAULT);
- status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i);
- if (status<0) {
+ status = H5HG_insert(f, H5P_DATASET_XFER_DEFAULT, size, out, obj + i);
+ if(status < 0) {
H5_FAILED();
puts(" Unable to insert object into global heap");
nerrors++;
- } else if (i && H5F_addr_gt (obj[i-1].addr, obj[i].addr)) {
+ } else if(i && H5F_addr_gt(obj[i - 1].addr, obj[i].addr)) {
H5_FAILED();
puts(" Collection addresses are not monotonically increasing");
nerrors++;
@@ -122,27 +122,28 @@ test_1 (hid_t fapl)
/*
* Now try to read each object back.
*/
- for (i=0; i<1024; i++) {
- size = i+1;
- memset (out, 'A'+i%26, size);
+ for(i = 0; i < 1024; i++) {
+ size = i + 1;
+ HDmemset(out, 'A' + i % 26, size);
H5Eclear2(H5E_DEFAULT);
- if (NULL==H5HG_read (f, H5P_DATASET_XFER_DEFAULT, obj+i, in, NULL)) {
+ if(NULL == H5HG_read(f, H5P_DATASET_XFER_DEFAULT, obj + i, in, NULL)) {
H5_FAILED();
puts(" Unable to read object");
nerrors++;
- } else if (memcmp (in, out, size)) {
+ } else if(HDmemcmp(in, out, size)) {
H5_FAILED();
puts(" Value read doesn't match value written");
nerrors++;
}
}
- if (H5Fclose(file)<0) goto error;
- if (nerrors) goto error;
+ if(H5Fclose(file) < 0) goto error;
+ if(nerrors) goto error;
+
PASSED();
return 0;
- error:
+error:
H5E_BEGIN_TRY {
H5Fclose(file);
} H5E_END_TRY;
@@ -170,23 +171,23 @@ test_1 (hid_t fapl)
static int
test_2 (hid_t fapl)
{
- hid_t file=-1;
- H5F_t *f=NULL;
+ hid_t file = -1;
+ H5F_t *f = NULL;
H5HG_t obj[1024];
uint8_t out[1024];
uint8_t in[1024];
int i;
size_t size;
- int nerrors=0;
+ int nerrors = 0;
char filename[1024];
TESTING("monotonically decreasing lengths");
/* Open a clean file */
h5_fixname(FILENAME[1], fapl, filename, sizeof filename);
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
- if (NULL==(f=H5I_object(file))) {
+ if(NULL == (f = (H5F_t *)H5I_object(file))) {
H5_FAILED();
puts(" Unable to create file");
goto error;
@@ -257,23 +258,23 @@ test_2 (hid_t fapl)
static int
test_3 (hid_t fapl)
{
- hid_t file=-1;
- H5F_t *f=NULL;
+ hid_t file = -1;
+ H5F_t *f = NULL;
H5HG_t obj[1024];
uint8_t out[1024];
int i;
size_t size;
herr_t status;
- int nerrors=0;
+ int nerrors = 0;
char filename[1024];
TESTING("complete object removal");
/* Open a clean file */
h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
- if (NULL==(f=H5I_object(file))) {
+ if(NULL == (f = (H5F_t *)H5I_object(file))) {
H5_FAILED();
puts(" Unable to create file");
goto error;
@@ -336,23 +337,23 @@ test_3 (hid_t fapl)
static int
test_4 (hid_t fapl)
{
- hid_t file=-1;
- H5F_t *f=NULL;
+ hid_t file = -1;
+ H5F_t *f = NULL;
H5HG_t obj[1024];
uint8_t out[1024];
int i;
size_t size;
herr_t status;
- int nerrors=0;
+ int nerrors = 0;
char filename[1024];
TESTING("partial object removal");
/* Open a clean file */
h5_fixname(FILENAME[3], fapl, filename, sizeof filename);
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
- if (NULL==(f=H5I_object(file))) {
+ if(NULL == (f = (H5F_t *)H5I_object(file))) {
H5_FAILED();
puts(" Unable to create file");
goto error;