summaryrefslogtreecommitdiffstats
path: root/test/gheap.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-08-20 21:37:12 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-08-20 21:37:12 (GMT)
commit47c3bc7540869f53f0b734c68d3289835f0a546d (patch)
tree90e688dc21b095d9d3d36e944465ac79eff05348 /test/gheap.c
parentb2012d9f74843ec87b31b7aca0c3ad8b6b6fe448 (diff)
downloadhdf5-47c3bc7540869f53f0b734c68d3289835f0a546d.zip
hdf5-47c3bc7540869f53f0b734c68d3289835f0a546d.tar.gz
hdf5-47c3bc7540869f53f0b734c68d3289835f0a546d.tar.bz2
[svn-r19272] Description:
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: Mac OS X/32 10.6.4 (amazon) w/debug & valgrind (h5committest forthcoming)
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;