From 1f8f6f019c85df6c031a32f6bf703fa18e225973 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 15 Jan 2020 09:32:01 -0800 Subject: Fixed stack and frame size warnings. Not complete, but fixes most of the easier cases. --- src/H5Sselect.c | 40 ++- test/dsets.c | 673 ++++++++++++++++++++++++++----------- test/efc.c | 31 +- test/err_compat.c | 35 +- test/error_test.c | 31 +- test/extend.c | 181 +++++----- test/fheap.c | 22 +- test/th5s.c | 59 +++- test/unregister.c | 23 +- test/vds.c | 161 ++++++--- test/vfd.c | 196 ++++++----- tools/src/h5import/h5import.c | 41 +-- tools/test/h5dump/h5dumpgentest.c | 58 +++- tools/test/misc/h5repart_gentest.c | 71 ++-- 14 files changed, 1117 insertions(+), 505 deletions(-) diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 9814e38..13233ce 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -2601,9 +2601,9 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, { H5S_t *new_space = NULL; /* New dataspace constructed */ H5S_t *tmp_src_intersect_space = NULL; /* Temporary SIS converted from points->hyperslabs */ - H5S_sel_iter_t ss_iter; /* Selection iterator for src_space */ + H5S_sel_iter_t *ss_iter = NULL; /* Selection iterator for src_space */ hbool_t ss_iter_init = FALSE; /* Whether ss_iter has been initialized */ - H5S_sel_iter_t ds_iter; /* Selection iterator for dst_space */ + H5S_sel_iter_t *ds_iter = NULL; /* Selection iterator for dst_space */ hbool_t ds_iter_init = FALSE; /* Whether ds_iter has been initialized */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2617,6 +2617,11 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HDassert(H5S_GET_SELECT_NPOINTS(src_space) == H5S_GET_SELECT_NPOINTS(dst_space)); HDassert(H5S_GET_EXTENT_NDIMS(src_space) == H5S_GET_EXTENT_NDIMS(src_intersect_space)); + if(NULL == (ss_iter = H5FL_CALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") + if(NULL == (ds_iter = H5FL_CALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") + /* Create new space, using dst extent. Start with "all" selection. */ if(NULL == (new_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create output dataspace") @@ -2717,20 +2722,20 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Initialize iterators */ - if(H5S_select_iter_init(&ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + if(H5S_select_iter_init(ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize source space selection iterator") ss_iter_init = TRUE; - if(H5S_select_iter_init(&ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + if(H5S_select_iter_init(ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize destination space selection iterator") ds_iter_init = TRUE; /* Iterate over points */ do { - HDassert(ss_iter.elmt_left > 0); - HDassert(ss_iter.elmt_left > 0); + HDassert(ss_iter->elmt_left > 0); + HDassert(ss_iter->elmt_left > 0); /* Get SS coords */ - if(H5S_SELECT_ITER_COORDS(&ss_iter, coords) < 0) + if(H5S_SELECT_ITER_COORDS(ss_iter, coords) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get source selection coordinates") /* Check for intersection */ @@ -2740,7 +2745,7 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Add point if it intersects */ if(intersect) { /* Get DS coords */ - if(H5S_SELECT_ITER_COORDS(&ds_iter, coords) < 0) + if(H5S_SELECT_ITER_COORDS(ds_iter, coords) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get destination selection coordinates") /* Add point to new_space */ @@ -2749,14 +2754,14 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, } /* end if */ /* Advance iterators */ - if(H5S_SELECT_ITER_NEXT(&ss_iter, 1) < 0) + if(H5S_SELECT_ITER_NEXT(ss_iter, 1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne source selection iterator") - ss_iter.elmt_left--; - if(H5S_SELECT_ITER_NEXT(&ds_iter, 1) < 0) + ss_iter->elmt_left--; + if(H5S_SELECT_ITER_NEXT(ds_iter, 1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne destination selection iterator") - ds_iter.elmt_left--; - } while(ss_iter.elmt_left > 0); - HDassert(H5S_SELECT_ITER_NELMTS(&ds_iter) == 0); + ds_iter->elmt_left--; + } while(ss_iter->elmt_left > 0); + HDassert(H5S_SELECT_ITER_NELMTS(ds_iter) == 0); } /* end if */ else { HDassert(H5S_GET_SELECT_TYPE(src_space) != H5S_SEL_NONE); @@ -2783,11 +2788,14 @@ done: /* General cleanup */ if(tmp_src_intersect_space && H5S_close(tmp_src_intersect_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release temporary dataspace") - if(ss_iter_init && H5S_SELECT_ITER_RELEASE(&ss_iter) < 0) + if(ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release source selection iterator") - if(ds_iter_init && H5S_SELECT_ITER_RELEASE(&ds_iter) < 0) + if(ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release destination selection iterator") + ss_iter = H5FL_FREE(H5S_sel_iter_t, ss_iter); + ds_iter = H5FL_FREE(H5S_sel_iter_t, ds_iter); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_project_intersection() */ diff --git a/test/dsets.c b/test/dsets.c index a394210..237a050 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -272,10 +272,16 @@ const char *FILENAME[] = { /* Shared global arrays */ #define DSET_DIM1 100 #define DSET_DIM2 200 -int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2]; -double points_dbl[DSET_DIM1][DSET_DIM2], check_dbl[DSET_DIM1][DSET_DIM2]; -size_t count_nbytes_read = 0; -size_t count_nbytes_written = 0; +int **points = NULL; +int *points_data = NULL; +double **points_dbl = NULL; +double *points_dbl_data = NULL; +int **check = NULL; +int *check_data = NULL; +double **check_dbl = NULL; +double *check_dbl_data = NULL; +size_t count_nbytes_read = 0; +size_t count_nbytes_written = 0; /* Temporary buffer dimensions */ #define DSET_TMP_DIM1 50 @@ -511,7 +517,8 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) void *tconv_buf = NULL; int f = -1; haddr_t offset; - int rdata[DSET_DIM1][DSET_DIM2]; + int **rdata = NULL; + int *rdata_bytes = NULL; TESTING("simple I/O"); @@ -519,6 +526,14 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { h5_fixname(FILENAME[4], fapl, filename, sizeof filename); + /* Set up data array */ + if(NULL == (rdata_bytes = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + TEST_ERROR; + if(NULL == (rdata = (int **)HDcalloc(DSET_DIM1, sizeof(rdata_bytes)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + rdata[i] = rdata_bytes + (i * DSET_DIM2); + /* Initialize the dataset */ for(i = n = 0; i < DSET_DIM1; i++) for(j = 0; j < DSET_DIM2; j++) @@ -548,7 +563,7 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) if(H5Dget_offset(dataset) != HADDR_UNDEF) goto error; /* Write the data to the dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points) < 0) + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points_data) < 0) goto error; /* Test dataset address in file. Open the same file as a C file, seek @@ -557,7 +572,7 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) if((offset=H5Dget_offset(dataset))==HADDR_UNDEF) goto error; /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check_data) < 0) goto error; /* Check that the values read are the same as the values written */ @@ -581,7 +596,7 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) f = HDopen(filename, O_RDONLY); HDlseek(f, (off_t)offset, SEEK_SET); - if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) + if(HDread(f, rdata_bytes, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) goto error; /* Check that the values read are the same as the values written */ @@ -600,6 +615,9 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) f = -1; HDfree(tconv_buf); + HDfree(rdata_bytes); + HDfree(rdata); + PASSED(); } /* end if */ else { @@ -620,8 +638,11 @@ error: if(H5Fclose(file) < 0) TEST_ERROR if(f > 0) HDclose(f); - if(tconv_buf) - HDfree(tconv_buf); + + HDfree(tconv_buf); + HDfree(rdata_bytes); + HDfree(rdata); + return FAIL; } /* end test_simple_io() */ @@ -644,7 +665,8 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) hsize_t dims[2]; int f = -1; haddr_t offset; - int rdata[DSET_DIM1][DSET_DIM2]; + int **rdata = NULL; + int *rdata_bytes = NULL; TESTING("dataset offset with user block"); @@ -652,6 +674,14 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { h5_fixname(FILENAME[2], fapl, filename, sizeof filename); + /* Set up data array */ + if(NULL == (rdata_bytes = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + TEST_ERROR; + if(NULL == (rdata = (int **)HDcalloc(DSET_DIM1, sizeof(rdata_bytes)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + rdata[i] = rdata_bytes + (i * DSET_DIM2); + if((fcpl=H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; if(H5Pset_userblock(fcpl, (hsize_t)USER_BLOCK) < 0) goto error; if(new_format) @@ -675,7 +705,7 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) space = -1; /* Write the data to the dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) goto error; /* Test dataset address in file. Open the same file as a C file, seek @@ -690,7 +720,7 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) f = HDopen(filename, O_RDONLY); HDlseek(f, (off_t)offset, SEEK_SET); - if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) + if(HDread(f, rdata_bytes, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) goto error; /* Check that the values read are the same as the values written */ @@ -708,6 +738,9 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) HDclose(f); f = -1; + HDfree(rdata_bytes); + HDfree(rdata); + PASSED(); } /* end if */ else { @@ -728,6 +761,10 @@ error: if(H5Fclose(file) < 0) TEST_ERROR if(f > 0) HDclose(f); + + HDfree(rdata_bytes); + HDfree(rdata); + return FAIL; } /* end test_userblock_offset() */ @@ -1786,7 +1823,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, */ TESTING(" filters (uninitialized read)"); - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; for(i=0; i<(size_t)size[0]; i++) { @@ -1815,7 +1852,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, } } - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0) + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points_data) < 0) TEST_ERROR; if((*dset_size=H5Dget_storage_size(dataset))==0) TEST_ERROR; @@ -1833,25 +1870,25 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, /* Default behavior is failure when data is corrupted. */ /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR; /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; } else { - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ @@ -1885,33 +1922,33 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, points[i][j] = (int)HDrandom (); } } - if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0) + if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points_data) < 0) TEST_ERROR; if(corrupted) { /* Default behavior is failure when data is corrupted. */ /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR; /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; } else { /* Read the dataset back and check it */ - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ @@ -1946,13 +1983,13 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, /* Default behavior is failure when data is corrupted. */ /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status >= 0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ @@ -1960,12 +1997,12 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status >= 0) TEST_ERROR; } /* end if */ else { - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ @@ -1999,32 +2036,32 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) TEST_ERROR; /* (Use the "read" DXPL because partial I/O on corrupted data test needs to ignore errors during writing) */ - if(H5Dwrite (dataset, H5T_NATIVE_INT, sid, sid, dxpl, points) < 0) + if(H5Dwrite (dataset, H5T_NATIVE_INT, sid, sid, dxpl, points_data) < 0) TEST_ERROR; if(corrupted) { /* Default behavior is failure when data is corrupted. */ /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR; /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; } else { - if(H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check) < 0) + if(H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ @@ -2629,7 +2666,7 @@ test_missing_filter(hid_t file) } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) { + if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error writing dataset data\n",__LINE__); goto error; @@ -2658,7 +2695,7 @@ test_missing_filter(hid_t file) } /* end if */ /* Read data */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) { + if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error reading dataset data\n",__LINE__); goto error; @@ -2719,7 +2756,7 @@ test_missing_filter(hid_t file) /* Read data (should fail, since deflate filter is missing) */ H5E_BEGIN_TRY { - ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check); + ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data); } H5E_END_TRY; if(ret>=0) { H5_FAILED(); @@ -4127,149 +4164,164 @@ test_nbit_int_size(hid_t file) hid_t dataspace, dataset, datatype, mem_datatype, dset_create_props; hsize_t dims[2], chunk_size[2]; hsize_t dset_size = 0; - int orig_data[DSET_DIM1][DSET_DIM2]; + int **orig = NULL; + int *orig_data = NULL; double power; int i, j; size_t precision, offset; TESTING(" nbit integer dataset size"); - /* Define dataset datatype (integer), and set precision, offset */ - if((datatype = H5Tcopy(H5T_NATIVE_INT)) < 0) { - H5_FAILED(); - HDprintf(" line %d: H5Tcopy failed\n",__LINE__); - goto error; - } /* end if */ + /* Set up data array */ + if(NULL == (orig_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + TEST_ERROR; + if(NULL == (orig = (int **)HDcalloc(DSET_DIM1, sizeof(orig_data)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + orig[i] = orig_data + (i * DSET_DIM2); - precision = 16; /* precision includes sign bit */ - if(H5Tset_precision(datatype,precision)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_precision failed\n",__LINE__); - goto error; - } /* end if */ + /* Define dataset datatype (integer), and set precision, offset */ + if((datatype = H5Tcopy(H5T_NATIVE_INT)) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Tcopy failed\n",__LINE__); + goto error; + } - offset = 8; - if(H5Tset_offset(datatype,offset)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Tset_offset failed\n",__LINE__); - goto error; - } /* end if */ + precision = 16; /* precision includes sign bit */ + if(H5Tset_precision(datatype,precision)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_precision failed\n",__LINE__); + goto error; + } - /* Copy to memory datatype */ - if((mem_datatype = H5Tcopy(datatype)) < 0) { - H5_FAILED(); - HDprintf(" line %d: H5Tcopy failed\n",__LINE__); - goto error; - } /* end if */ + offset = 8; + if(H5Tset_offset(datatype,offset)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Tset_offset failed\n",__LINE__); + goto error; + } - /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE)<0) { + /* Copy to memory datatype */ + if((mem_datatype = H5Tcopy(datatype)) < 0) { H5_FAILED(); - HDprintf(" line %d: H5Pset_order failed\n",__LINE__); - goto error; - } /* end if */ + HDprintf(" line %d: H5Tcopy failed\n",__LINE__); + goto error; + } - if(H5Tset_size(datatype, 4)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_size failed\n",__LINE__); - goto error; - } /* end if */ + /* Set order of dataset datatype */ + if(H5Tset_order(datatype, H5T_ORDER_BE)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_order failed\n",__LINE__); + goto error; + } - /* Initiliaze data buffer with random data within correct range - * corresponding to the memory datatype's precision and offset. - */ - for (i=0; i < DSET_DIM1; i++) - for (j=0; j < DSET_DIM2; j++) { - power = HDpow(2.0F, (double)(precision-1)); - orig_data[i][j] = HDrandom() % (int)power << offset; - } /* end for */ + if(H5Tset_size(datatype, 4)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_size failed\n",__LINE__); + goto error; + } + /* Initiliaze data buffer with random data within correct range + * corresponding to the memory datatype's precision and offset. + */ + for (i=0; i < DSET_DIM1; i++) + for (j=0; j < DSET_DIM2; j++) { + power = HDpow(2.0F, (double)(precision-1)); + orig[i][j] = HDrandom() % (int)power << offset; + } - /* Describe the dataspace. */ - dims[0] = DSET_DIM1; - dims[1] = DSET_DIM2; - if((dataspace = H5Screate_simple (2, dims, NULL))<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pcreate failed\n",__LINE__); - goto error; - } /* end if */ - /* - * Set the dataset creation property list to specify the chunks - */ - chunk_size[0] = DSET_DIM1/10; - chunk_size[1] = DSET_DIM2/10; - if((dset_create_props = H5Pcreate (H5P_DATASET_CREATE))<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pcreate failed\n",__LINE__); - goto error; - } /* end if */ + /* Describe the dataspace. */ + dims[0] = DSET_DIM1; + dims[1] = DSET_DIM2; + if((dataspace = H5Screate_simple(2, dims, NULL))<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pcreate failed\n",__LINE__); + goto error; + } - if(H5Pset_chunk (dset_create_props, 2, chunk_size)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_chunk failed\n",__LINE__); - goto error; - } /* end if */ + /* + * Set the dataset creation property list to specify the chunks + */ + chunk_size[0] = DSET_DIM1/10; + chunk_size[1] = DSET_DIM2/10; + if((dset_create_props = H5Pcreate(H5P_DATASET_CREATE))<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pcreate failed\n",__LINE__); + goto error; + } - /* - * Set for n-bit compression - */ - if(H5Pset_nbit (dset_create_props)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_nbit failed\n",__LINE__); - goto error; - } /* end if */ + if(H5Pset_chunk(dset_create_props, 2, chunk_size)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_chunk failed\n",__LINE__); + goto error; + } - /* - * Create a new dataset within the file. - */ - if((dataset = H5Dcreate2 (file, DSET_NBIT_INT_SIZE_NAME, datatype, + /* + * Set for n-bit compression + */ + if(H5Pset_nbit(dset_create_props)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_nbit failed\n",__LINE__); + goto error; + } + + /* + * Create a new dataset within the file. + */ + if((dataset = H5Dcreate2(file, DSET_NBIT_INT_SIZE_NAME, datatype, dataspace, H5P_DEFAULT, dset_create_props, H5P_DEFAULT))<0) { - H5_FAILED(); - HDprintf(" line %d: H5dwrite failed\n",__LINE__); - goto error; - } /* end if */ + H5_FAILED(); + HDprintf(" line %d: H5dwrite failed\n",__LINE__); + goto error; + } - /* - * Write the array to the file. - */ - if(H5Dwrite (dataset, mem_datatype, H5S_ALL, H5S_ALL, - H5P_DEFAULT, orig_data)<0) { - H5_FAILED(); - HDprintf(" Line %d: H5Dwrite failed\n",__LINE__); - goto error; - } /* end if */ + /* + * Write the array to the file. + */ + if(H5Dwrite(dataset, mem_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data)<0) { + H5_FAILED(); + HDprintf(" Line %d: H5Dwrite failed\n",__LINE__); + goto error; + } - /* - * Get the precision of the data type - */ - if((precision = H5Tget_precision(datatype)) == 0) { - H5_FAILED(); - HDprintf(" Line %d: wrong precision size: %zu\n",__LINE__, precision); - goto error; - } /* end if */ + /* + * Get the precision of the data type + */ + if((precision = H5Tget_precision(datatype)) == 0) { + H5_FAILED(); + HDprintf(" Line %d: wrong precision size: %zu\n",__LINE__, precision); + goto error; + } - /* - * The size of the dataset after compression should around 2 * DSET_DIM1 * DSET_DIM2 - */ - if((dset_size = H5Dget_storage_size(dataset)) < DSET_DIM1*DSET_DIM2*(precision/8) || - dset_size > DSET_DIM1*DSET_DIM2*(precision/8) + 1*KB) { - H5_FAILED(); - HDfprintf(stdout, " Line %d: wrong dataset size: %Hu\n",__LINE__, dset_size); - goto error; - } /* end if */ + /* + * The size of the dataset after compression should around 2 * DSET_DIM1 * DSET_DIM2 + */ + if((dset_size = H5Dget_storage_size(dataset)) < DSET_DIM1*DSET_DIM2*(precision/8) || + dset_size > DSET_DIM1*DSET_DIM2*(precision/8) + 1*KB) { + H5_FAILED(); + HDfprintf(stdout, " Line %d: wrong dataset size: %Hu\n",__LINE__, dset_size); + goto error; + } - H5Tclose (datatype); - H5Tclose (mem_datatype); - H5Dclose (dataset); - H5Sclose (dataspace); - H5Pclose (dset_create_props); + H5Tclose(datatype); + H5Tclose(mem_datatype); + H5Dclose(dataset); + H5Sclose(dataspace); + H5Pclose(dset_create_props); + + HDfree(orig); + HDfree(orig_data); PASSED(); - return SUCCEED; + return SUCCEED; + error: + HDfree(orig); + HDfree(orig_data); + return FAIL; } /* end test_nbit_int_size() */ @@ -4295,13 +4347,22 @@ test_nbit_flt_size(hid_t file) hid_t dataspace, dataset, datatype, dset_create_props; hsize_t dims[2], chunk_size[2]; hsize_t dset_size = 0; - float orig_data[DSET_DIM1][DSET_DIM2]; + float **orig = NULL; + float *orig_data = NULL; int i, j; size_t precision, offset; size_t spos, epos, esize, mpos, msize; TESTING(" nbit floating-number dataset size"); + /* Set up data array */ + if(NULL == (orig_data = (float *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(float)))) + TEST_ERROR; + if(NULL == (orig = (float **)HDcalloc(DSET_DIM1, sizeof(orig_data)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + orig[i] = orig_data + (i * DSET_DIM2); + /* Define floating-point type for dataset *------------------------------------------------------------------- * size=4 byte, precision=16 bits, offset=8 bits, @@ -4380,7 +4441,7 @@ test_nbit_flt_size(hid_t file) */ for (i=0; i < DSET_DIM1; i++) for (j=0; j < DSET_DIM2; j++) - orig_data[i][j] = (float)(HDrandom() % 1234567) / 2; + orig[i][j] = (float)(HDrandom() % 1234567) / 2; /* Describe the dataspace. */ @@ -4465,8 +4526,14 @@ test_nbit_flt_size(hid_t file) PASSED(); + HDfree(orig); + HDfree(orig_data); + return SUCCEED; error: + HDfree(orig); + HDfree(orig_data); + return FAIL; } /* end test_nbit_flt_size() */ @@ -5460,7 +5527,7 @@ test_can_apply(hid_t file) } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) { + if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error writing dataset data\n",__LINE__); goto error; @@ -5488,7 +5555,7 @@ test_can_apply(hid_t file) } /* end if */ /* Read data */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) { + if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error reading dataset data\n",__LINE__); goto error; @@ -5619,7 +5686,7 @@ test_can_apply2(hid_t file) } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) { + if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error writing dataset data\n",__LINE__); goto error; @@ -5647,7 +5714,7 @@ test_can_apply2(hid_t file) } /* end if */ /* Read data */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) { + if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error reading dataset data\n",__LINE__); goto error; @@ -5988,7 +6055,7 @@ test_set_local(hid_t fapl) } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) { + if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error writing dataset data\n",__LINE__); goto error; @@ -6010,7 +6077,7 @@ test_set_local(hid_t fapl) } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_dbl) < 0) { + if(H5Dwrite(dsid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_dbl_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error writing dataset data\n",__LINE__); goto error; @@ -6073,7 +6140,7 @@ test_set_local(hid_t fapl) } /* end if */ /* Read data */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) { + if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error reading dataset data\n", __LINE__); goto error; @@ -6123,7 +6190,7 @@ test_set_local(hid_t fapl) } /* end if */ /* Read data */ - if(H5Dread(dsid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_dbl) < 0) { + if(H5Dread(dsid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_dbl_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error reading dataset data\n", __LINE__); goto error; @@ -6856,10 +6923,12 @@ test_missing_chunk(hid_t file) hsize_t hs_start2[2], hs_stride2[2], hs_count2[2], hs_block2[2];/* Hyperslab setting */ /* Buffers for reading/writing dataset */ - int wdata[MISSING_CHUNK_DIM], - rdata[MISSING_CHUNK_DIM]; - int wdata2[MISSING_CHUNK_DIM][MISSING_CHUNK_DIM], - rdata2[MISSING_CHUNK_DIM][MISSING_CHUNK_DIM]; + int *wdata = NULL; + int *rdata = NULL; + int **wdata2 = NULL; + int **rdata2 = NULL; + int *wdata2_bytes = NULL; + int *rdata2_bytes = NULL; /* Setting for 1-D dataset */ hsize_t dsize=100, dmax=H5S_UNLIMITED; @@ -6876,6 +6945,26 @@ test_missing_chunk(hid_t file) TESTING("Read dataset with unwritten chunk & undefined fill value"); + /* Set up data arrays */ + if(NULL == (wdata = (int *)HDcalloc(MISSING_CHUNK_DIM, sizeof(int)))) + TEST_ERROR; + if(NULL == (rdata = (int *)HDcalloc(MISSING_CHUNK_DIM, sizeof(int)))) + TEST_ERROR; + + if(NULL == (wdata2_bytes = (int *)HDcalloc(MISSING_CHUNK_DIM * MISSING_CHUNK_DIM, sizeof(int)))) + TEST_ERROR; + if(NULL == (wdata2 = (int **)HDcalloc(MISSING_CHUNK_DIM, sizeof(wdata2_bytes)))) + TEST_ERROR; + for (i = 0; i < MISSING_CHUNK_DIM; i++) + wdata2[i] = wdata2_bytes + (i * MISSING_CHUNK_DIM); + + if(NULL == (rdata2_bytes = (int *)HDcalloc(MISSING_CHUNK_DIM * MISSING_CHUNK_DIM, sizeof(int)))) + TEST_ERROR; + if(NULL == (rdata2 = (int **)HDcalloc(MISSING_CHUNK_DIM, sizeof(rdata2_bytes)))) + TEST_ERROR; + for (i = 0; i < MISSING_CHUNK_DIM; i++) + rdata2[i] = rdata2_bytes + (i * MISSING_CHUNK_DIM); + /* Get the file's file access property list */ if((fapl = H5Fget_access_plist(file)) < 0) TEST_ERROR; @@ -6893,10 +6982,10 @@ test_missing_chunk(hid_t file) /* Initialize data for 2-D dataset */ for(i = 0; i < MISSING_CHUNK_DIM; i++) { - for(j = 0; j < MISSING_CHUNK_DIM; j++) { - wdata2[i][j] = (int)(j + (i * MISSING_CHUNK_DIM)); - rdata2[i][j] = 911; - } + for(j = 0; j < MISSING_CHUNK_DIM; j++) { + wdata2[i][j] = (int)(j + (i * MISSING_CHUNK_DIM)); + rdata2[i][j] = 911; + } } /* end for */ /* Create dataspace */ @@ -6954,11 +7043,11 @@ test_missing_chunk(hid_t file) /* Write selected data to the datasets */ if(H5Dwrite(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, wdata) < 0) TEST_ERROR; - if(H5Dwrite(did2, H5T_NATIVE_INT, sid2, sid2, H5P_DEFAULT, wdata2) < 0) TEST_ERROR; + if(H5Dwrite(did2, H5T_NATIVE_INT, sid2, sid2, H5P_DEFAULT, wdata2_bytes) < 0) TEST_ERROR; /* Read all data from the datasets */ if(H5Dread(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR; - if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata2) < 0) TEST_ERROR; + if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata2_bytes) < 0) TEST_ERROR; /* Validata values read for the 1-D dataset */ for(u=0; u max_size[0] || size[1] > max_size[1]) { if(size[0] > max_size[0]) max_size[0] = size[0]; @@ -78,42 +83,41 @@ write_data(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t me if(H5Dset_extent(dataset, max_size) < 0) TEST_ERROR; } /* end if */ - /* Select a hyperslab */ + /* Select a hyperslab */ if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; + if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; - /* Write to the hyperslab */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1) < 0) TEST_ERROR; + /* Write to the hyperslab */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1_data) < 0) TEST_ERROR; if(H5Sclose(file_space) < 0) TEST_ERROR; - } /* end for */ + } /* end for */ /* Read the data */ if((half_space = H5Screate_simple(2, half_dims, NULL)) < 0) TEST_ERROR; if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; for(i = 0; i < 10; i++) { - for(j = 0; j < 10; j++) { - - /* Select a hyperslab */ - offset[0] = (hsize_t)(i * (NX / 2)); - offset[1] = (hsize_t)(j * (NY / 2)); - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; - - /* Read */ - if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2) < 0) TEST_ERROR; - - /* Compare */ - for(k = 0; k < (NX / 2); k++) - for(m = 0; m < (NY / 2); m++) - if(buf2[k][m] != buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]) { - HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); - HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); - HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * (NX / 2) + k, (j % 2) * (NY / 2) + m, buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]); - TEST_ERROR; - } /* end if */ - } /* end for */ + for(j = 0; j < 10; j++) { + + /* Select a hyperslab */ + offset[0] = (hsize_t)(i * N2X); + offset[1] = (hsize_t)(j * N2Y); + if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; + + /* Read */ + if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2_data) < 0) TEST_ERROR; + + /* Compare */ + for(k = 0; k < N2X; k++) + for(m = 0; m < N2Y; m++) + if(buf2[k][m] != buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]) { + HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); + HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); + HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * N2X + k, (j % 2) * N2Y + m, buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]); + TEST_ERROR; + } /* end if */ + } /* end for */ } /* end for */ - /* Cleanup */ if(H5Dclose(dataset) < 0) TEST_ERROR; if(H5Sclose(file_space) < 0) TEST_ERROR; @@ -146,8 +150,8 @@ static int write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t mem_space) { hid_t dataset, file_space, half_space; - static const hsize_t dims[2] = {NX, NY}; - static const hsize_t half_dims[2] = {NX / 2, NY / 2}; + static const hsize_t dims[2] = {N1X, N1Y}; + static const hsize_t half_dims[2] = {N2X, N2Y}; static hsize_t size[2]; hsize_t offset[2]; int i, j, k, m; @@ -159,48 +163,48 @@ write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, h /* Write the data */ for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) { + for(j = 0; j < 5; j++) { - /* Extend the dataset */ - offset[0] = (hsize_t)(i * NX); - offset[1] = (hsize_t)(j * NY); - size[0] = offset[0] + NX; - size[1] = offset[1] + NY; - if(H5Dextend(dataset, size) < 0) TEST_ERROR; + /* Extend the dataset */ + offset[0] = (hsize_t)(i * N1X); + offset[1] = (hsize_t)(j * N1Y); + size[0] = offset[0] + N1X; + size[1] = offset[1] + N1Y; + if(H5Dextend(dataset, size) < 0) TEST_ERROR; - /* Select a hyperslab */ + /* Select a hyperslab */ if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; + if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; - /* Write to the hyperslab */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1) < 0) TEST_ERROR; + /* Write to the hyperslab */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1_data) < 0) TEST_ERROR; if(H5Sclose(file_space) < 0) TEST_ERROR; - } /* end for */ + } /* end for */ /* Read the data */ if((half_space = H5Screate_simple(2, half_dims, NULL)) < 0) TEST_ERROR; if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; for(i = 0; i < 10; i++) { - for(j = 0; j < 10; j++) { - - /* Select a hyperslab */ - offset[0] = (hsize_t)(i * (NX / 2)); - offset[1] = (hsize_t)(j * (NY / 2)); - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; - - /* Read */ - if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2) < 0) TEST_ERROR; - - /* Compare */ - for(k = 0; k < (NX / 2); k++) - for(m = 0; m < (NY / 2); m++) - if(buf2[k][m] != buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]) { - HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); - HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); - HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * (NX / 2) + k, (j % 2) * (NY / 2) + m, buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]); - TEST_ERROR; - } /* end if */ - } /* end for */ + for(j = 0; j < 10; j++) { + + /* Select a hyperslab */ + offset[0] = (hsize_t)(i * N2X); + offset[1] = (hsize_t)(j * N2Y); + if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; + + /* Read */ + if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2_data) < 0) TEST_ERROR; + + /* Compare */ + for(k = 0; k < N2X; k++) + for(m = 0; m < N2Y; m++) + if(buf2[k][m] != buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]) { + HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); + HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); + HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * N2X + k, (j % 2) * N2Y + m, buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]); + TEST_ERROR; + } /* end if */ + } /* end for */ } /* end for */ @@ -236,8 +240,8 @@ main (void) hid_t file, mem_space, cparms; hid_t fapl; int nerrors = 0; - static const hsize_t dims[2] = {NX, NY}; - static const hsize_t chunk_dims[2] = {NX/2, NY/2}; + static const hsize_t dims[2] = {N1X, N1Y}; + static const hsize_t chunk_dims[2] = {N2X, N2Y}; static hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; char filename[1024]; int i, j; @@ -246,9 +250,23 @@ main (void) fapl = h5_fileaccess(); /* Initialize buffer and space */ - for(i = 0; i < NX; i++) - for(j = 0; j < NY; j++) - buf1[i][j] = i * NY + j; + if(NULL == (buf1_data = (int *)HDcalloc(N1X * N1Y, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf1 = (int **)HDcalloc(N1X, sizeof(buf1_data)))) + TEST_ERROR; + for (i = 0; i < N1X; i++) + buf1[i] = buf1_data + (i * N1Y); + + if(NULL == (buf2_data = (int *)HDcalloc(N2X * N2Y, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf2 = (int **)HDcalloc(N2X, sizeof(buf2_data)))) + TEST_ERROR; + for (i = 0; i < N2X; i++) + buf2[i] = buf2_data + (i * N2Y); + + for(i = 0; i < N1X; i++) + for(j = 0; j < N1Y; j++) + buf1[i][j] = i * N1Y + j; if((mem_space = H5Screate_simple(2, dims, maxdims)) < 0) TEST_ERROR; @@ -288,9 +306,20 @@ main (void) HDprintf("All extend tests passed.\n"); h5_cleanup(FILENAME, fapl); + HDfree(buf1); + HDfree(buf1_data); + HDfree(buf2); + HDfree(buf2_data); + HDexit(EXIT_SUCCESS); error: + + HDfree(buf1); + HDfree(buf1_data); + HDfree(buf2); + HDfree(buf2_data); + HDprintf("*** One or more extend tests failed ***\n"); HDexit(EXIT_FAILURE); } /* end main() */ diff --git a/test/fheap.c b/test/fheap.c index 2cd2be3..b8c54d6 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -7617,7 +7617,8 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ - unsigned char heap_id[100][MAX_HEAP_ID_LEN]; /* Heap ID for object inserted */ + unsigned char **heap_id = NULL; + unsigned char *heap_id_data = NULL; struct a_type_t1 { char a[10]; char b[40]; @@ -7629,6 +7630,14 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + /* Set up data array */ + if(NULL == (heap_id_data = (unsigned char *)HDcalloc(100 * MAX_HEAP_ID_LEN, sizeof(unsigned char)))) + TEST_ERROR; + if(NULL == (heap_id = (unsigned char **)HDcalloc(100, sizeof(heap_id_data)))) + TEST_ERROR; + for (i = 0; i < 100; i++) + heap_id[i] = heap_id_data + (i * MAX_HEAP_ID_LEN); + /* Create the file to work on */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR @@ -7695,7 +7704,10 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ /* All tests passed */ PASSED() - return(0); + HDfree(heap_id); + HDfree(heap_id_data); + + return 0; error: H5E_BEGIN_TRY { @@ -7703,7 +7715,11 @@ error: H5HF_close(fh); H5Fclose(file); } H5E_END_TRY; - return(1); + + HDfree(heap_id); + HDfree(heap_id_data); + + return 1; } /* test_man_incr_insert_remove() */ #endif /* QAK */ diff --git a/test/th5s.c b/test/th5s.c index 7e1e547..c60b1ff 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -2459,11 +2459,12 @@ test_h5s_compound_scalar_read(void) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5s_compound_scalar_read() */ +} /* end test_h5s_compound_scalar_read() */ -/* Data arrays for chunk test */ -double chunk_data_dbl[50000][3]; -float chunk_data_flt[50000][3]; + +/* Data array sizes for chunk test */ +#define CHUNK_DATA_NX 50000 +#define CHUNK_DATA_NY 3 /**************************************************************** ** @@ -2481,22 +2482,41 @@ test_h5s_chunk(void) hid_t space_id; hsize_t dims[2]; hsize_t csize[2]; + double **chunk_data_dbl = NULL; + double *chunk_data_dbl_data = NULL; + float **chunk_data_flt = NULL; + float *chunk_data_flt_data = NULL; int i,j; + /* Allocate memory */ + chunk_data_dbl_data = (double *)HDcalloc(CHUNK_DATA_NX * CHUNK_DATA_NY, sizeof(double)); + CHECK_PTR(chunk_data_dbl_data, "HDcalloc"); + chunk_data_dbl = (double **)HDcalloc(CHUNK_DATA_NX, sizeof(chunk_data_dbl_data)); + CHECK_PTR(chunk_data_dbl, "HDcalloc"); + for (i = 0; i < CHUNK_DATA_NX; i++) + chunk_data_dbl[i] = chunk_data_dbl_data + (i * CHUNK_DATA_NY); + + chunk_data_flt_data = (float *)HDcalloc(CHUNK_DATA_NX * CHUNK_DATA_NY, sizeof(float)); + CHECK_PTR(chunk_data_flt_data, "HDcalloc"); + chunk_data_flt = (float **)HDcalloc(CHUNK_DATA_NX, sizeof(chunk_data_flt_data)); + CHECK_PTR(chunk_data_flt, "HDcalloc"); + for (i = 0; i < CHUNK_DATA_NX; i++) + chunk_data_flt[i] = chunk_data_flt_data + (i * CHUNK_DATA_NY); + fileID = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fileID, FAIL, "H5Fcreate"); plist_id = H5Pcreate(H5P_DATASET_CREATE); CHECK(plist_id, FAIL, "H5Pcreate"); - csize[0] = 50000; - csize[1] = 3; + csize[0] = CHUNK_DATA_NX; + csize[1] = CHUNK_DATA_NY; status = H5Pset_chunk(plist_id, 2, csize); CHECK(status, FAIL, "H5Pset_chunk"); /* Create the dataspace */ - dims[0] = 50000; - dims[1] = 3; + dims[0] = CHUNK_DATA_NX; + dims[1] = CHUNK_DATA_NY; space_id = H5Screate_simple(2, dims, NULL); CHECK(space_id, FAIL, "H5Screate_simple"); @@ -2504,11 +2524,11 @@ test_h5s_chunk(void) CHECK(dsetID, FAIL, "H5Dcreate2"); /* Initialize float array */ - for(i = 0; i < 50000; i++) - for(j = 0; j < 3; j++) + for(i = 0; i < CHUNK_DATA_NX; i++) + for(j = 0; j < CHUNK_DATA_NY; j++) chunk_data_flt[i][j] = (float)(i + 1) * 2.5F - (float)j * 100.3F; - status = H5Dwrite(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt); + status = H5Dwrite(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt_data); CHECK(status, FAIL, "H5Dwrite"); status = H5Pclose(plist_id); @@ -2521,17 +2541,17 @@ test_h5s_chunk(void) CHECK(status, FAIL, "H5Fclose"); /* Reset/initialize the data arrays to read in */ - HDmemset(chunk_data_dbl, 0, sizeof(double) * 50000 * 3); - HDmemset(chunk_data_flt, 0, sizeof(float) * 50000 * 3); + HDmemset(chunk_data_dbl_data, 0, sizeof(double) * CHUNK_DATA_NX * CHUNK_DATA_NY); + HDmemset(chunk_data_flt_data, 0, sizeof(float) * CHUNK_DATA_NX * CHUNK_DATA_NY); fileID = H5Fopen(DATAFILE, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fileID, FAIL, "H5Fopen"); dsetID = H5Dopen2(fileID, "coords", H5P_DEFAULT); CHECK(dsetID, FAIL, "H5Dopen2"); - status= H5Dread(dsetID, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_dbl); + status= H5Dread(dsetID, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_dbl_data); CHECK(status, FAIL, "H5Dread"); - status= H5Dread(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt); + status= H5Dread(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt_data); CHECK(status, FAIL, "H5Dread"); status = H5Dclose(dsetID); @@ -2539,13 +2559,18 @@ test_h5s_chunk(void) status = H5Fclose(fileID); CHECK(status, FAIL, "H5Fclose"); - for(i=0; i<50000; i++) { - for(j=0; j<3; j++) { + for(i = 0; i < CHUNK_DATA_NX; i++) { + for(j = 0; j < CHUNK_DATA_NY; j++) { /* Check if the two values are within 0.001% range. */ if(!H5_DBL_REL_EQUAL(chunk_data_dbl[i][j], (double)chunk_data_flt[i][j], (double)0.00001F)) TestErrPrintf("%u: chunk_data_dbl[%d][%d]=%e, chunk_data_flt[%d][%d]=%e\n", (unsigned)__LINE__, i, j, chunk_data_dbl[i][j], i, j, (double)chunk_data_flt[i][j]); } /* end for */ } /* end for */ + + HDfree(chunk_data_dbl); + HDfree(chunk_data_dbl_data); + HDfree(chunk_data_flt); + HDfree(chunk_data_flt_data); } /* test_h5s_chunk() */ /**************************************************************** diff --git a/test/unregister.c b/test/unregister.c index ff116cf..db37f3e 100644 --- a/test/unregister.c +++ b/test/unregister.c @@ -95,11 +95,20 @@ test_unregister_filters(hid_t fapl_id) char filename[FILENAME_BUF_SIZE]; const hsize_t chunk_dims[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ hsize_t dims[2]; - int data[DSET_DIM1][DSET_DIM2]; + int **buf = NULL; + int *buf_data = NULL; herr_t ret; TESTING("Unregistering filter"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(DSET_DIM1, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + buf[i] = buf_data + (i * DSET_DIM2); + /* Create first file */ h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); if((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) @@ -176,7 +185,7 @@ test_unregister_filters(hid_t fapl_id) /* Initialize the data for writing */ for(i = n = 0; i < DSET_DIM1; i++) for(j = 0; j < DSET_DIM2; j++) - data[i][j] = n++; + buf[i][j] = n++; /* Create the dataspace */ dims[0] = DSET_DIM1; @@ -189,7 +198,7 @@ test_unregister_filters(hid_t fapl_id) goto error; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) goto error; /* Unregister the filter before closing the dataset. It should fail */ @@ -211,7 +220,7 @@ test_unregister_filters(hid_t fapl_id) goto error; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) goto error; /* Close the dataset in the second file */ @@ -232,6 +241,9 @@ test_unregister_filters(hid_t fapl_id) if(H5Fclose(fid2) < 0) goto error; + HDfree(buf); + HDfree(buf_data); + PASSED(); return SUCCEED; @@ -247,6 +259,9 @@ error: H5Sclose(sid); } H5E_END_TRY; + HDfree(buf); + HDfree(buf_data); + return FAIL; } diff --git a/test/vds.c b/test/vds.c index f724e67..6994f1b 100644 --- a/test/vds.c +++ b/test/vds.c @@ -1134,11 +1134,11 @@ error: static int test_vds_prefix_first(unsigned config, hid_t fapl) { - char srcfilename[FILENAME_BUF_SIZE]; - char srcfilename_map[FILENAME_BUF_SIZE]; - char vfilename[FILENAME_BUF_SIZE]; - char srcfilenamepct[FILENAME_BUF_SIZE]; - char srcfilenamepct_map[FILENAME_BUF_SIZE]; + char *srcfilename = NULL; + char *srcfilename_map = NULL; + char *vfilename = NULL; + char *srcfilenamepct = NULL; + char *srcfilenamepct_map = NULL; const char *srcfilenamepct_map_orig = "vds%%%%_src"; hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ hid_t vfile = -1; /* File with virtual dset */ @@ -1158,11 +1158,22 @@ test_vds_prefix_first(unsigned config, hid_t fapl) TESTING("basic virtual dataset I/O via H5Pset_vds_prefix(): all selection") - h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); - h5_fixname(FILENAME[8], fapl, srcfilename, sizeof srcfilename); - h5_fixname_printf(FILENAME[8], fapl, srcfilename_map, sizeof srcfilename_map); - h5_fixname(FILENAME[10], fapl, srcfilenamepct, sizeof srcfilenamepct); - h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, sizeof srcfilenamepct_map); + if((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + + h5_fixname(FILENAME[0], fapl, vfilename, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[8], fapl, srcfilename, FILENAME_BUF_SIZE); + h5_fixname_printf(FILENAME[8], fapl, srcfilename_map, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[10], fapl, srcfilenamepct, FILENAME_BUF_SIZE); + h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, FILENAME_BUF_SIZE); /* create tmp directory and get current working directory path */ if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) @@ -1346,6 +1357,12 @@ test_vds_prefix_first(unsigned config, hid_t fapl) TEST_ERROR dcpl = -1; + HDfree(srcfilename); + HDfree(srcfilename_map); + HDfree(vfilename); + HDfree(srcfilenamepct); + HDfree(srcfilenamepct_map); + PASSED(); return 0; @@ -1369,6 +1386,12 @@ test_vds_prefix_first(unsigned config, hid_t fapl) if(HDsetenv("HDF5_VDS_PREFIX", "", 1) < 0) TEST_ERROR + HDfree(srcfilename); + HDfree(srcfilename_map); + HDfree(vfilename); + HDfree(srcfilenamepct); + HDfree(srcfilenamepct_map); + return 1; } /* end test_vds_prefix */ @@ -1386,12 +1409,12 @@ test_vds_prefix_first(unsigned config, hid_t fapl) static int test_basic_io(unsigned config, hid_t fapl) { - char srcfilename[FILENAME_BUF_SIZE]; - char srcfilename_map[FILENAME_BUF_SIZE]; - char vfilename[FILENAME_BUF_SIZE]; - char vfilename2[FILENAME_BUF_SIZE]; - char srcfilenamepct[FILENAME_BUF_SIZE]; - char srcfilenamepct_map[FILENAME_BUF_SIZE]; + char *srcfilename = NULL; + char *srcfilename_map = NULL; + char *vfilename = NULL; + char *vfilename2 = NULL; + char *srcfilenamepct = NULL; + char *srcfilenamepct_map = NULL; const char *srcfilenamepct_map_orig = "vds%%%%_src"; hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ hid_t vfile = -1; /* File with virtual dset */ @@ -1419,12 +1442,25 @@ test_basic_io(unsigned config, hid_t fapl) TESTING("basic virtual dataset I/O") - h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); - h5_fixname(FILENAME[1], fapl, vfilename2, sizeof vfilename2); - h5_fixname(FILENAME[2], fapl, srcfilename, sizeof srcfilename); - h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, sizeof srcfilename_map); - h5_fixname(FILENAME[4], fapl, srcfilenamepct, sizeof srcfilenamepct); - h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, sizeof srcfilenamepct_map); + if((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((vfilename2 = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + + h5_fixname(FILENAME[0], fapl, vfilename, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[1], fapl, vfilename2, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[2], fapl, srcfilename, FILENAME_BUF_SIZE); + h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[4], fapl, srcfilenamepct, FILENAME_BUF_SIZE); + h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, FILENAME_BUF_SIZE); /* Create DCPL */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -4227,6 +4263,13 @@ test_basic_io(unsigned config, hid_t fapl) TEST_ERROR dcpl = -1; + HDfree(srcfilename); + HDfree(srcfilename_map); + HDfree(vfilename); + HDfree(vfilename2); + HDfree(srcfilenamepct); + HDfree(srcfilenamepct_map); + PASSED(); return 0; @@ -4247,6 +4290,13 @@ error: H5Pclose(dcpl); } H5E_END_TRY; + HDfree(srcfilename); + HDfree(srcfilename_map); + HDfree(vfilename); + HDfree(vfilename2); + HDfree(srcfilenamepct); + HDfree(srcfilenamepct_map); + return 1; } /* end test_basic_io() */ @@ -7286,15 +7336,15 @@ error: static int test_printf(unsigned config, hid_t fapl) { - char srcfilename[FILENAME_BUF_SIZE]; - char srcfilename_map[FILENAME_BUF_SIZE]; - char srcfilename2[FILENAME_BUF_SIZE]; - char srcfilename2_map[FILENAME_BUF_SIZE]; - char vfilename[FILENAME_BUF_SIZE]; - char printf_srcfilename_map[FILENAME_BUF_SIZE]; + char *srcfilename = NULL; + char *srcfilename_map = NULL; + char *srcfilename2 = NULL; + char *srcfilename2_map = NULL; + char *vfilename = NULL; + char *printf_srcfilename_map = NULL; + char *srcfilenamepct = NULL; + char *srcfilenamepct_map = NULL; const char *printf_srcfilename_map_orig = "vds_src_%b"; - char srcfilenamepct[FILENAME_BUF_SIZE]; - char srcfilenamepct_map[FILENAME_BUF_SIZE]; const char *srcfilenamepct_map_orig = "vds%%%%_src"; hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ hid_t vfile = -1; /* File with virtual dset */ @@ -7322,14 +7372,31 @@ test_printf(unsigned config, hid_t fapl) TESTING("virtual dataset I/O with printf source") - h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); - h5_fixname(FILENAME[2], fapl, srcfilename, sizeof srcfilename); - h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, sizeof srcfilename_map); - h5_fixname(FILENAME[3], fapl, srcfilename2, sizeof srcfilename2); - h5_fixname_printf(FILENAME[2], fapl, srcfilename2_map, sizeof srcfilename2_map); - h5_fixname_printf(printf_srcfilename_map_orig, fapl, printf_srcfilename_map, sizeof printf_srcfilename_map); - h5_fixname(FILENAME[4], fapl, srcfilenamepct, sizeof srcfilenamepct); - h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, sizeof srcfilenamepct_map); + if((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilename2 = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilename2_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((printf_srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + + h5_fixname(FILENAME[0], fapl, vfilename, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[2], fapl, srcfilename, FILENAME_BUF_SIZE); + h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[3], fapl, srcfilename2, FILENAME_BUF_SIZE); + h5_fixname_printf(FILENAME[2], fapl, srcfilename2_map, FILENAME_BUF_SIZE); + h5_fixname_printf(printf_srcfilename_map_orig, fapl, printf_srcfilename_map, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[4], fapl, srcfilenamepct, FILENAME_BUF_SIZE); + h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, FILENAME_BUF_SIZE); /* Create DCPL */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -10940,6 +11007,15 @@ test_printf(unsigned config, hid_t fapl) TEST_ERROR memspace = -1; + HDfree(srcfilename); + HDfree(srcfilename_map); + HDfree(srcfilename2); + HDfree(srcfilename2_map); + HDfree(vfilename); + HDfree(printf_srcfilename_map); + HDfree(srcfilenamepct); + HDfree(srcfilenamepct_map); + PASSED(); return 0; @@ -10960,6 +11036,15 @@ error: H5Pclose(dapl); } H5E_END_TRY; + HDfree(srcfilename); + HDfree(srcfilename_map); + HDfree(srcfilename2); + HDfree(srcfilename2_map); + HDfree(vfilename); + HDfree(printf_srcfilename_map); + HDfree(srcfilenamepct); + HDfree(srcfilenamepct_map); + return 1; } /* end test_printf() */ diff --git a/test/vfd.c b/test/vfd.c index 4fc61da..c033de5 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -842,8 +842,7 @@ error: * * Purpose: Tests the file handle interface for FAMILY driver * - * Return: Success: 0 - * Failure: -1 + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 @@ -861,12 +860,21 @@ test_family(void) char dname[]="dataset"; unsigned int i, j; int *fhandle=NULL, *fhandle2=NULL; - int buf[FAMILY_NUMBER][FAMILY_SIZE]; + int **buf = NULL; + int *buf_data = NULL; hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE}; hsize_t file_size; TESTING("FAMILY file driver"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < FAMILY_NUMBER; i++) + buf[i] = buf_data + (i * FAMILY_SIZE); + /* Set property list and file name for FAMILY driver */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; @@ -890,7 +898,7 @@ test_family(void) | H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; if(H5Fclose(file) < 0) @@ -905,7 +913,7 @@ test_family(void) if(H5Pset_fapl_family(fapl, (hsize_t)H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; - if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Check file size API */ @@ -917,7 +925,7 @@ test_family(void) TEST_ERROR; /* Create and write dataset */ - if((space=H5Screate_simple(2, dims, NULL)) < 0) + if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; /* Retrieve the access property list... */ @@ -932,14 +940,14 @@ test_family(void) if (H5Pclose(access_fapl) < 0) TEST_ERROR; - if((dset=H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; for(i = 0; i < FAMILY_NUMBER; i++) for(j = 0; j < FAMILY_SIZE; j++) buf[i][j] = (int)((i * 10000) + j); - if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR; /* check file handle API */ @@ -1004,8 +1012,11 @@ test_family(void) if(H5Pclose(fapl) < 0) TEST_ERROR; + HDfree(buf); + HDfree(buf_data); + PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -1015,8 +1026,12 @@ error: H5Pclose(fapl2); H5Fclose(file); } H5E_END_TRY; - return -1; -} + + HDfree(buf); + HDfree(buf_data); + + return FAIL; +} /* end test_family() */ /*------------------------------------------------------------------------- @@ -1136,8 +1151,7 @@ error: * * Purpose: Actually use the member fapl input to the member vfd. * - * Return: Success: 0 - * Failure: -1 + * Return: SUCCEED/FAIL * * Programmer: Jacob Smith * 21 May 2019 @@ -1147,108 +1161,91 @@ error: static herr_t test_family_member_fapl(void) { - hid_t file = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t memb_fapl_id = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t dset = H5I_INVALID_HID; + hid_t file = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t memb_fapl_id = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; char filename[1024]; - char dname[] = "dataset"; - unsigned i = 0; - unsigned j = 0; - int buf[FAMILY_NUMBER][FAMILY_SIZE]; - hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE}; + char dname[] = "dataset"; + unsigned i = 0; + unsigned j = 0; + int **buf = NULL; + int *buf_data = NULL; + hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE}; TESTING("Family member FAPL"); - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5I_INVALID_HID == fapl_id) { + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int)))) TEST_ERROR; - } - memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5I_INVALID_HID == memb_fapl_id) { + if(NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data)))) TEST_ERROR; - } - if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) { + for (i = 0; i < FAMILY_NUMBER; i++) + buf[i] = buf_data + (i * FAMILY_SIZE); + + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID) TEST_ERROR; - } - if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL) { + + if((memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID) TEST_ERROR; - } + + if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) + TEST_ERROR; + if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL) + TEST_ERROR; + h5_fixname(FILENAME[2], fapl_id, filename, sizeof(filename)); - file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if (H5I_INVALID_HID == file) { + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) == H5I_INVALID_HID) TEST_ERROR; - } - space = H5Screate_simple(2, dims, NULL); - if (H5I_INVALID_HID == space) { + if((space = H5Screate_simple(2, dims, NULL)) == H5I_INVALID_HID) TEST_ERROR; - } /* Create and write to dataset, then close file. */ - dset = H5Dcreate2( - file, - dname, - H5T_NATIVE_INT, - space, - H5P_DEFAULT, - H5P_DEFAULT, - H5P_DEFAULT); - if (H5I_INVALID_HID == dset) { + if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) == H5I_INVALID_HID) TEST_ERROR; - } + for (i = 0; i < FAMILY_NUMBER; i++) { for (j = 0; j < FAMILY_SIZE; j++) { buf[i][j] = (int)((i * 10000) + j); } } - if (H5Dwrite(dset, - H5T_NATIVE_INT, - H5S_ALL, - H5S_ALL, - H5P_DEFAULT, - buf) - == FAIL) - { + + if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) == FAIL) TEST_ERROR; - } - if (H5Dclose(dset) == FAIL) { + + if (H5Dclose(dset) == FAIL) TEST_ERROR; - } - if (H5Sclose(space) == FAIL) { + if (H5Sclose(space) == FAIL) TEST_ERROR; - } - if (H5Fclose(file) == FAIL) { + if (H5Fclose(file) == FAIL) TEST_ERROR; - } /* "Close" member FAPL at top level and re-open file. * Should succeed, with library managing reference count properly */ - if (H5Pclose(memb_fapl_id) == FAIL) { + if (H5Pclose(memb_fapl_id) == FAIL) TEST_ERROR; - } - file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) == H5I_INVALID_HID) TEST_ERROR; - } - if (H5Fclose(file) == FAIL) { + if (H5Fclose(file) == FAIL) TEST_ERROR; - } h5_delete_test_file(FILENAME[2], fapl_id); - if (H5Pclose(fapl_id) == FAIL) { + if (H5Pclose(fapl_id) == FAIL) TEST_ERROR; - } + + HDfree(buf); + HDfree(buf_data); PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -1259,7 +1256,10 @@ error: H5Fclose(file); } H5E_END_TRY; - return -1; + HDfree(buf); + HDfree(buf_data); + + return FAIL; } /* end test_family_member_fapl() */ @@ -1337,10 +1337,19 @@ test_multi(void) char dname[]="dataset"; char meta[] = "this is some metadata on this file"; int i, j; - int buf[MULTI_SIZE][MULTI_SIZE]; + int **buf = NULL; + int *buf_data = NULL; TESTING("MULTI file driver"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(MULTI_SIZE * MULTI_SIZE, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(MULTI_SIZE, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < MULTI_SIZE; i++) + buf[i] = buf_data + (i * MULTI_SIZE); + /* Set file access property list for MULTI driver */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; @@ -1443,7 +1452,7 @@ test_multi(void) for(i=0; ifcount < 29) { + (void) HDstrcpy(opt->infiles[opt->fcount].datafile, argv[i]); + in = &(opt->infiles[opt->fcount].in); + opt->infiles[opt->fcount].config = 0; + setDefaultValues(in, opt->fcount); + opt->fcount++; } else { (void) HDfprintf(stderr, err9, argv[i]); @@ -148,8 +148,8 @@ int main(int argc, char *argv[]) break; case 3: /* get configfile name */ - (void) HDstrcpy(opt.infiles[opt.fcount-1].configfile, argv[i]); - opt.infiles[opt.fcount - 1].config = 1; + (void) HDstrcpy(opt->infiles[opt->fcount-1].configfile, argv[i]); + opt->infiles[opt->fcount - 1].config = 1; break; case 4: /* -o found; look for outfile */ @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) (void) HDfprintf(stderr, err10, argv[i]); goto err; } - (void) HDstrcpy(opt.outfile, argv[i]); + (void) HDstrcpy(opt->outfile, argv[i]); outfile_named = TRUE; break; @@ -232,11 +232,11 @@ int main(int argc, char *argv[]) goto err; } - if (process(&opt) == -1) + if (process(opt) == -1) goto err; - for (i = 0; i < opt.fcount; i++) { - in = &(opt.infiles[i].in); + for (i = 0; i < opt->fcount; i++) { + in = &(opt->infiles[i].in); if (in->sizeOfDimension) HDfree(in->sizeOfDimension); if (in->sizeOfChunk) @@ -248,12 +248,13 @@ int main(int argc, char *argv[]) if (in->data) HDfree(in->data); } + HDfree(opt); - return (EXIT_SUCCESS); + return EXIT_SUCCESS; err: (void) HDfprintf(stderr, "%s", err4); - for (i = 0; i < opt.fcount; i++) { - in = &(opt.infiles[i].in); + for (i = 0; i < opt->fcount; i++) { + in = &(opt->infiles[i].in); if (in->sizeOfDimension) HDfree(in->sizeOfDimension); if (in->sizeOfChunk) @@ -265,7 +266,9 @@ err: if (in->data) HDfree(in->data); } - return (EXIT_FAILURE); + HDfree(opt); + + return EXIT_FAILURE; } static int gtoken(char *s) diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c index d0421d2..7fa97d6 100644 --- a/tools/test/h5dump/h5dumpgentest.c +++ b/tools/test/h5dump/h5dumpgentest.c @@ -463,10 +463,23 @@ gent_dataset(void) { hid_t fid, dataset, space; hsize_t dims[2]; - int dset1[10][20]; - double dset2[30][20]; + int **dset1 = NULL; + int *dset1_data = NULL; + double **dset2 = NULL; + double *dset2_data = NULL; int i, j; + /* Set up data arrays */ + dset1_data = (int *)HDcalloc(10 * 20, sizeof(int)); + dset1 = (int **)HDcalloc(10, sizeof(dset1_data)); + for (i = 0; i < 10; i++) + dset1[i] = dset1_data + (i * 20); + + dset2_data = (double *)HDcalloc(30 * 20, sizeof(double)); + dset2 = (double **)HDcalloc(30, sizeof(dset2_data)); + for (i = 0; i < 30; i++) + dset2[i] = dset2_data + (i * 20); + fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* dset1 */ @@ -478,7 +491,7 @@ gent_dataset(void) for(j = 0; j < 20; j++) dset1[i][j] = j + i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1_data); H5Sclose(space); H5Dclose(dataset); @@ -491,11 +504,16 @@ gent_dataset(void) for(j = 0; j < 20; j++) dset2[i][j] = 0.0001F * (float)j + (float)i; - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); + H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_data); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dset1); + HDfree(dset1_data); + HDfree(dset2); + HDfree(dset2_data); } static void @@ -1773,9 +1791,17 @@ static void gent_str(void) { int a[8][10]; char s[12][33]; } compound_t; - compound_t comp1[3][6]; + + compound_t **comp1 = NULL; + compound_t *comp1_data = NULL; hsize_t mdims[2]; + /* Set up data array */ + comp1_data = (compound_t *)HDcalloc(3 * 6, sizeof(compound_t)); + comp1 = (compound_t **)HDcalloc(3, sizeof(comp1_data)); + for (i = 0; i < 3; i++) + comp1[i] = comp1_data + (i * 6); + fid = H5Fcreate(FILE13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* string 1 : nullterm string */ @@ -1861,7 +1887,7 @@ static void gent_str(void) { } dataset = H5Dcreate2(fid, "/comp1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, f_type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, comp1); + H5Dwrite(dataset, f_type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, comp1_data); H5Tclose(f_type); H5Tclose(f_type2); @@ -1869,6 +1895,9 @@ static void gent_str(void) { H5Dclose(dataset); H5Fclose(fid); + + HDfree(comp1); + HDfree(comp1_data); } /* @@ -3748,9 +3777,15 @@ void gent_multi(void) H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; + char **sv = NULL; + char *sv_data = NULL; haddr_t memb_addr[H5FD_MEM_NTYPES]; + sv_data = (char *)HDcalloc(H5FD_MEM_NTYPES * 1024, sizeof(char)); + sv = (char **)HDcalloc(H5FD_MEM_NTYPES, sizeof(sv_data)); + for (i = 0; i < H5FD_MEM_NTYPES; i++) + sv[i] = sv_data + (i * 1024); + fapl = H5Pcreate(H5P_FILE_ACCESS); HDmemset(memb_map, 0, sizeof memb_map); @@ -3791,6 +3826,9 @@ void gent_multi(void) H5Dclose(dataset); H5Fclose(fid); H5Pclose(fapl); + + HDfree(sv); + HDfree(sv_data); } static void gent_large_objname(void) @@ -7959,7 +7997,7 @@ static void gent_compound_attr_intsizes(void) { int64_t dset64[F70_XDIM][F70_YDIM64]; double dsetdbl[F70_XDIM][F70_YDIM8]; } Array1Struct; - Array1Struct Array1[F70_LENGTH]; + Array1Struct *Array1 = NULL; hid_t Array1Structid; /* File datatype identifier */ herr_t status; /* Error checking variable */ @@ -7967,6 +8005,8 @@ static void gent_compound_attr_intsizes(void) { int m, n, o; /* Array init loop vars */ + Array1 = (Array1Struct *)HDcalloc(F70_LENGTH, sizeof(Array1Struct)); + /* Initialize the data in the arrays/datastructure */ for (m = 0; m < F70_LENGTH; m++) { @@ -8198,6 +8238,8 @@ static void gent_compound_attr_intsizes(void) { status = H5Fclose(fid); HDassert(status >= 0); + + HDfree(Array1); } static void gent_nested_compound_dt(void) { /* test nested data type */ diff --git a/tools/test/misc/h5repart_gentest.c b/tools/test/misc/h5repart_gentest.c index 5c1ff87..bd94104 100644 --- a/tools/test/misc/h5repart_gentest.c +++ b/tools/test/misc/h5repart_gentest.c @@ -25,7 +25,8 @@ #define FAMILY_SIZE 1024 #define FILENAME "family_file%05d.h5" -static int buf[FAMILY_NUMBER][FAMILY_SIZE]; +int **buf = NULL; +int *buf_data = NULL; int main(void) { @@ -34,66 +35,82 @@ int main(void) int i, j; hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE}; + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int)))) { + HDperror("HDcalloc"); + HDexit(EXIT_FAILURE); + } + if(NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data)))) { + HDperror("HDcalloc"); + HDexit(EXIT_FAILURE); + } + for (i = 0; i < FAMILY_NUMBER; i++) + buf[i] = buf_data + (i * FAMILY_SIZE); + /* Set property list and file name for FAMILY driver */ - if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) { - perror ("H5Pcreate"); - exit (EXIT_FAILURE); + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + HDperror("H5Pcreate"); + HDexit(EXIT_FAILURE); } if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) { - perror ("H5Pset_fapl_family"); - exit (EXIT_FAILURE); + HDperror("H5Pset_fapl_family"); + HDexit(EXIT_FAILURE); } if((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { - perror("H5Fcreate"); - exit(EXIT_FAILURE); + HDperror("H5Fcreate"); + HDexit(EXIT_FAILURE); } /* Create and write dataset */ if((space = H5Screate_simple(2, dims, NULL)) < 0) { - perror("H5Screate_simple"); - exit(EXIT_FAILURE); + HDperror("H5Screate_simple"); + HDexit(EXIT_FAILURE); } if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - perror("H5Dcreate2"); - exit(EXIT_FAILURE); + HDperror("H5Dcreate2"); + HDexit(EXIT_FAILURE); } - for(i = 0; i