summaryrefslogtreecommitdiffstats
path: root/tools/test/perform
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2021-11-23 14:09:05 (GMT)
committerGitHub <noreply@github.com>2021-11-23 14:09:05 (GMT)
commit462e9a373f810eda51f4bc3c6415d6130b2a3cac (patch)
treedf3d2687c84d9be85bb758ee48f5ee15c7578799 /tools/test/perform
parentb9e4deec10cc943a7ecb3ac6bc6bd6695b2f33a0 (diff)
downloadhdf5-462e9a373f810eda51f4bc3c6415d6130b2a3cac.zip
hdf5-462e9a373f810eda51f4bc3c6415d6130b2a3cac.tar.gz
hdf5-462e9a373f810eda51f4bc3c6415d6130b2a3cac.tar.bz2
Create 2D arrays on the heap in a different way (#1169)
* Create 2D arrays on the heap by malloc'ing `struct { TYPE arr[ROWS][COLS]; }`. This avoids the double-indirection through pointers and the additional memory of H5TEST_ALLOCATE_2D_ARRAY(). This change will safely quiet the cast warning that PR #1129 was intended to fix. * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'tools/test/perform')
-rw-r--r--tools/test/perform/chunk_cache.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/test/perform/chunk_cache.c b/tools/test/perform/chunk_cache.c
index a99334f..832447e 100644
--- a/tools/test/perform/chunk_cache.c
+++ b/tools/test/perform/chunk_cache.c
@@ -98,7 +98,9 @@ create_dset1(hid_t file)
hid_t dcpl = H5I_INVALID_HID;
hsize_t dims[RANK] = {DSET1_DIM1, DSET1_DIM2};
hsize_t chunk_dims[RANK] = {CHUNK1_DIM1, CHUNK1_DIM2};
- int ** data = NULL; /* data for writing */
+ struct {
+ int arr[DSET1_DIM1][DSET1_DIM2];
+ } *data = malloc(sizeof(*data));
/* Create the data space. */
if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0)
@@ -122,9 +124,8 @@ create_dset1(hid_t file)
0)
goto error;
- /* Create & fill array */
- H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET1_DIM1, DSET1_DIM2);
- H5TEST_FILL_2D_ARRAY(data, int, DSET1_DIM1, DSET1_DIM2);
+ /* Fill array */
+ H5TEST_FILL_2D_HEAP_ARRAY(data, int);
/* Write data to dataset */
if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
@@ -162,7 +163,9 @@ create_dset2(hid_t file)
hid_t dcpl = H5I_INVALID_HID;
hsize_t dims[RANK] = {DSET2_DIM1, DSET2_DIM2};
hsize_t chunk_dims[RANK] = {CHUNK2_DIM1, CHUNK2_DIM2};
- int ** data = NULL; /* data for writing */
+ struct {
+ int arr[DSET2_DIM1][DSET2_DIM2];
+ } *data = malloc(sizeof(*data));
/* Create the data space. */
if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0)
@@ -185,9 +188,8 @@ create_dset2(hid_t file)
0)
goto error;
- /* Create & fill array */
- H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET2_DIM1, DSET2_DIM2);
- H5TEST_FILL_2D_ARRAY(data, int, DSET2_DIM1, DSET2_DIM2);
+ /* Fill array */
+ H5TEST_FILL_2D_HEAP_ARRAY(data, int);
/* Write data to dataset */
if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)