summaryrefslogtreecommitdiffstats
path: root/test/use_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/use_common.c')
-rw-r--r--test/use_common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/use_common.c b/test/use_common.c
index 0ea2c83..8f78f3b 100644
--- a/test/use_common.c
+++ b/test/use_common.c
@@ -322,10 +322,12 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
rank = H5Sget_simple_extent_ndims(f_sid);
if (rank != UC_RANK) {
HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank);
+ HDfree(buffer);
return -1;
}
if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) {
HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n");
+ HDfree(buffer);
return -1;
}
HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", rank, (unsigned long long)(dims[0]),
@@ -334,12 +336,14 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
if (dims[0] != 0 || dims[1] != memdims[1] || dims[2] != memdims[2]) {
HDfprintf(stderr, "dataset is not empty. Got dims=(%llu,%llu,%llu)\n", (unsigned long long)dims[0],
(unsigned long long)dims[1], (unsigned long long)dims[2]);
+ HDfree(buffer);
return -1;
}
/* setup mem-space for buffer */
if ((m_sid = H5Screate_simple(rank, memdims, NULL)) < 0) {
HDfprintf(stderr, "H5Screate_simple for memory failed\n");
+ HDfree(buffer);
return -1;
}
@@ -360,6 +364,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
if (opts->use_swmr) {
if (H5Odisable_mdc_flushes(dsid) < 0) {
HDfprintf(stderr, "H5Odisable_mdc_flushes failed\n");
+ HDfree(buffer);
return -1;
}
}
@@ -368,12 +373,14 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
dims[0] = i + 1;
if (H5Dset_extent(dsid, dims) < 0) {
HDfprintf(stderr, "H5Dset_extent failed\n");
+ HDfree(buffer);
return -1;
}
/* Get the dataset's dataspace */
if ((f_sid = H5Dget_space(dsid)) < 0) {
HDfprintf(stderr, "H5Dset_extent failed\n");
+ HDfree(buffer);
return -1;
}
@@ -381,12 +388,14 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
/* Choose the next plane to write */
if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) {
HDfprintf(stderr, "Failed H5Sselect_hyperslab\n");
+ HDfree(buffer);
return -1;
}
/* Write plane to the dataset */
if (H5Dwrite(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0) {
HDfprintf(stderr, "Failed H5Dwrite\n");
+ HDfree(buffer);
return -1;
}
@@ -394,6 +403,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
if (opts->use_swmr) {
if (H5Oenable_mdc_flushes(dsid) < 0) {
HDfprintf(stderr, "H5Oenable_mdc_flushes failed\n");
+ HDfree(buffer);
return -1;
}
}
@@ -401,6 +411,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
/* flush file to make the just written plane available. */
if (H5Dflush(dsid) < 0) {
HDfprintf(stderr, "Failed to H5Fflush file\n");
+ HDfree(buffer);
return -1;
}
} /* end for each plane to write */
@@ -488,10 +499,12 @@ read_uc_file(hbool_t towait, options_t *opts)
rank = H5Sget_simple_extent_ndims(f_sid);
if (rank != UC_RANK) {
HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank);
+ HDfree(buffer);
return -1;
}
if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) {
HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n");
+ HDfree(buffer);
return -1;
}
HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", rank, (unsigned long long)(dims[0]),
@@ -502,12 +515,14 @@ read_uc_file(hbool_t towait, options_t *opts)
(unsigned long long)dims[0], (unsigned long long)dims[1], (unsigned long long)dims[2]);
HDfprintf(stderr, "But memdims=(%llu,%llu,%llu)\n", (unsigned long long)memdims[0],
(unsigned long long)memdims[1], (unsigned long long)memdims[2]);
+ HDfree(buffer);
return -1;
}
/* Setup mem-space for buffer */
if ((m_sid = H5Screate_simple(rank, memdims, NULL)) < 0) {
HDfprintf(stderr, "H5Screate_simple for memory failed\n");
+ HDfree(buffer);
return -1;
}
@@ -533,6 +548,7 @@ read_uc_file(hbool_t towait, options_t *opts)
HDprintf(".");
if (loops_waiting_for_plane >= 30) {
HDfprintf(stderr, "waited too long for new plane, quit.\n");
+ HDfree(buffer);
return -1;
}
}
@@ -550,6 +566,7 @@ read_uc_file(hbool_t towait, options_t *opts)
/* Get the dataset's dataspace */
if ((f_sid = H5Dget_space(dsid)) < 0) {
HDfprintf(stderr, "H5Dget_space failed\n");
+ HDfree(buffer);
return -1;
}
@@ -557,12 +574,14 @@ read_uc_file(hbool_t towait, options_t *opts)
/* Choose the next plane to read */
if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) {
HDfprintf(stderr, "H5Sselect_hyperslab failed\n");
+ HDfree(buffer);
return -1;
}
/* Read the plane from the dataset */
if (H5Dread(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0) {
HDfprintf(stderr, "H5Dread failed\n");
+ HDfree(buffer);
return -1;
}
@@ -594,12 +613,14 @@ read_uc_file(hbool_t towait, options_t *opts)
f_sid = H5Dget_space(dsid); /* Get filespace handle first. */
if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) {
HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n");
+ HDfree(buffer);
return -1;
}
} /* end while (expecting more planes to read) */
if (H5Fclose(fid) < 0) {
HDfprintf(stderr, "H5Fclose failed\n");
+ HDfree(buffer);
return -1;
}