From 462e9a373f810eda51f4bc3c6415d6130b2a3cac Mon Sep 17 00:00:00 2001 From: David Young Date: Tue, 23 Nov 2021 08:09:05 -0600 Subject: 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> --- test/h5test.h | 59 +-- tools/test/h5dump/h5dumpgentest.c | 731 ++++++++++++++++++++++---------------- tools/test/h5repack/h5repacktst.c | 132 +++---- tools/test/misc/h5clear_gentest.c | 26 +- tools/test/perform/chunk_cache.c | 18 +- 5 files changed, 529 insertions(+), 437 deletions(-) diff --git a/test/h5test.h b/test/h5test.h index 914a534..7b82b68 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -172,60 +172,19 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #define H5_EXCLUDE_MULTIPART_DRIVERS 0x01 #define H5_EXCLUDE_NON_MULTIPART_DRIVERS 0x02 -/* Macros to create and fill 2D arrays with a single heap allocation. - * These can be used to replace large stack and global arrays which raise - * warnings. - * - * The macros make a single heap allocation large enough to hold all the - * pointers and the data elements. The first part of the allocation holds - * the pointers, and the second part holds the data as a contiguous block - * in row-major order. - * - * To pass the data block to calls like H5Dread(), pass a pointer to the - * first array element as the data pointer (e.g., array[0] in a 2D array). - * - * The fill macro just fills the array with an increasing count value. - * - * Usage: - * - * int **array; - * - * H5TEST_ALLOCATE_2D_ARRAY(array, int, 5, 10); - * - * H5TEST_FILL_2D_ARRAY(array, int, 5, 10); - * - * (do stuff) - * - * HDfree(array); +/* Fill an array on the heap with an increasing count value. BUF + * is expected to point to a `struct { TYPE arr[...][...]; }`. */ -#define H5TEST_ALLOCATE_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \ - do { \ - /* Prefix with h5taa to avoid shadow warnings */ \ - size_t h5taa_pointers_size = 0; \ - size_t h5taa_data_size = 0; \ - int h5taa_i; \ - \ - h5taa_pointers_size = (DIMS_I) * sizeof(TYPE *); \ - h5taa_data_size = (DIMS_I) * (DIMS_J) * sizeof(TYPE); \ - \ - ARR = (TYPE **)HDmalloc(h5taa_pointers_size + h5taa_data_size); \ - \ - ARR[0] = (TYPE *)(ARR + (DIMS_I)); \ - \ - for (h5taa_i = 1; h5taa_i < (DIMS_I); h5taa_i++) \ - ARR[h5taa_i] = ARR[h5taa_i - 1] + (DIMS_J); \ - } while (0) - -#define H5TEST_FILL_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \ +#define H5TEST_FILL_2D_HEAP_ARRAY(BUF, TYPE) \ do { \ /* Prefix with h5tfa to avoid shadow warnings */ \ - int h5tfa_i = 0; \ - int h5tfa_j = 0; \ - TYPE h5tfa_count = 0; \ + size_t h5tfa_i = 0; \ + size_t h5tfa_j = 0; \ + TYPE h5tfa_count = 0; \ \ - for (h5tfa_i = 0; h5tfa_i < (DIMS_I); h5tfa_i++) \ - for (h5tfa_j = 0; h5tfa_j < (DIMS_J); h5tfa_j++) { \ - ARR[h5tfa_i][h5tfa_j] = h5tfa_count; \ + for (h5tfa_i = 0; h5tfa_i < NELMTS((BUF)->arr); h5tfa_i++) \ + for (h5tfa_j = 0; h5tfa_j < NELMTS((BUF)->arr[0]); h5tfa_j++) { \ + (BUF)->arr[h5tfa_i][h5tfa_j] = h5tfa_count; \ h5tfa_count++; \ } \ } while (0) diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c index 7efe53c..b62c3a8 100644 --- a/tools/test/h5dump/h5dumpgentest.c +++ b/tools/test/h5dump/h5dumpgentest.c @@ -7264,15 +7264,33 @@ gent_packedbits(void) hid_t space = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t ** dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t ** dset8 = NULL; - int16_t ** dset16 = NULL; - int32_t ** dset32 = NULL; - int64_t ** dset64 = NULL; - double ** dsetdbl = NULL; + struct { + uint8_t arr[F66_XDIM][F66_YDIM8]; + } * dsetu8; + struct { + uint16_t arr[F66_XDIM][F66_YDIM16]; + } * dsetu16; + struct { + uint32_t arr[F66_XDIM][F66_YDIM32]; + } * dsetu32; + struct { + uint64_t arr[F66_XDIM][F66_YDIM64]; + } * dsetu64; + struct { + int8_t arr[F66_XDIM][F66_YDIM8]; + } * dset8; + struct { + int16_t arr[F66_XDIM][F66_YDIM16]; + } * dset16; + struct { + int32_t arr[F66_XDIM][F66_YDIM32]; + } * dset32; + struct { + int64_t arr[F66_XDIM][F66_YDIM64]; + } * dset64; + struct { + double arr[F66_XDIM][F66_YDIM8]; + } * dsetdbl; uint8_t valu8bits; uint16_t valu16bits; @@ -7286,15 +7304,15 @@ gent_packedbits(void) unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); fid = H5Fcreate(FILE66, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -7306,13 +7324,13 @@ gent_packedbits(void) valu8bits = (uint8_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu8[i][0] = valu8bits; + dsetu8->arr[i][0] = valu8bits; for (j = 1; j < dims[1]; j++) - dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); valu8bits = (uint8_t)(valu8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8[0]); + H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); H5Sclose(space); H5Dclose(dataset); @@ -7324,13 +7342,13 @@ gent_packedbits(void) valu16bits = (uint16_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu16[i][0] = valu16bits; + dsetu16->arr[i][0] = valu16bits; for (j = 1; j < dims[1]; j++) - dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); valu16bits = (uint16_t)(valu16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16[0]); + H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); H5Sclose(space); H5Dclose(dataset); @@ -7342,13 +7360,13 @@ gent_packedbits(void) valu32bits = (uint32_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu32[i][0] = valu32bits; + dsetu32->arr[i][0] = valu32bits; for (j = 1; j < dims[1]; j++) - dsetu32[i][j] = dsetu32[i][j - 1] << 1; + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; valu32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32[0]); + H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); H5Sclose(space); H5Dclose(dataset); @@ -7360,13 +7378,13 @@ gent_packedbits(void) valu64bits = (uint64_t)~0Lu; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu64[i][0] = valu64bits; + dsetu64->arr[i][0] = valu64bits; for (j = 1; j < dims[1]; j++) - dsetu64[i][j] = dsetu64[i][j - 1] << 1; + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; valu64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64[0]); + H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); H5Sclose(space); H5Dclose(dataset); @@ -7378,13 +7396,13 @@ gent_packedbits(void) val8bits = (int8_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset8[i][0] = val8bits; + dset8->arr[i][0] = val8bits; for (j = 1; j < dims[1]; j++) - dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); val8bits = (int8_t)(val8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8[0]); + H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); H5Sclose(space); H5Dclose(dataset); @@ -7396,13 +7414,13 @@ gent_packedbits(void) val16bits = (int16_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset16[i][0] = val16bits; + dset16->arr[i][0] = val16bits; for (j = 1; j < dims[1]; j++) - dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); val16bits = (int16_t)(val16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16[0]); + H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); H5Sclose(space); H5Dclose(dataset); @@ -7414,13 +7432,13 @@ gent_packedbits(void) val32bits = (int32_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset32[i][0] = val32bits; + dset32->arr[i][0] = val32bits; for (j = 1; j < dims[1]; j++) - dset32[i][j] = dset32[i][j - 1] << 1; + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; val32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); + H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); H5Sclose(space); H5Dclose(dataset); @@ -7432,13 +7450,13 @@ gent_packedbits(void) val64bits = (int64_t)~0L; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset64[i][0] = val64bits; + dset64->arr[i][0] = val64bits; for (j = 1; j < dims[1]; j++) - dset64[i][j] = dset64[i][j - 1] << 1; + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; val64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); + H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); H5Sclose(space); H5Dclose(dataset); @@ -7450,9 +7468,9 @@ gent_packedbits(void) for (i = 0; i < dims[0]; i++) for (j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001 * (double)j + (double)i; + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); + H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); H5Sclose(space); H5Dclose(dataset); @@ -7489,15 +7507,33 @@ gent_attr_intsize(void) hid_t root = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t ** dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t ** dset8 = NULL; - int16_t ** dset16 = NULL; - int32_t ** dset32 = NULL; - int64_t ** dset64 = NULL; - double ** dsetdbl = NULL; + struct { + uint8_t arr[F66_XDIM][F66_YDIM8]; + } * dsetu8; + struct { + uint16_t arr[F66_XDIM][F66_YDIM16]; + } * dsetu16; + struct { + uint32_t arr[F66_XDIM][F66_YDIM32]; + } * dsetu32; + struct { + uint64_t arr[F66_XDIM][F66_YDIM64]; + } * dsetu64; + struct { + int8_t arr[F66_XDIM][F66_YDIM8]; + } * dset8; + struct { + int16_t arr[F66_XDIM][F66_YDIM16]; + } * dset16; + struct { + int32_t arr[F66_XDIM][F66_YDIM64]; + } * dset32; + struct { + int64_t arr[F66_XDIM][F66_YDIM64]; + } * dset64; + struct { + double arr[F66_XDIM][F66_YDIM8]; + } * dsetdbl; uint8_t valu8bits; uint16_t valu16bits; @@ -7511,15 +7547,15 @@ gent_attr_intsize(void) unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); fid = H5Fcreate(FILE69, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); @@ -7532,14 +7568,14 @@ gent_attr_intsize(void) valu8bits = (uint8_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu8[i][0] = valu8bits; + dsetu8->arr[i][0] = valu8bits; for (j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } - H5Awrite(attr, H5T_NATIVE_UINT8, dsetu8[0]); + H5Awrite(attr, H5T_NATIVE_UINT8, dsetu8); H5Sclose(space); H5Aclose(attr); @@ -7551,14 +7587,14 @@ gent_attr_intsize(void) valu16bits = (uint16_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu16[i][0] = valu16bits; + dsetu16->arr[i][0] = valu16bits; for (j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } - H5Awrite(attr, H5T_NATIVE_UINT16, dsetu16[0]); + H5Awrite(attr, H5T_NATIVE_UINT16, dsetu16); H5Sclose(space); H5Aclose(attr); @@ -7570,14 +7606,14 @@ gent_attr_intsize(void) valu32bits = (uint32_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu32[i][0] = valu32bits; + dsetu32->arr[i][0] = valu32bits; for (j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j - 1] << 1; + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; } valu32bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_UINT32, dsetu32[0]); + H5Awrite(attr, H5T_NATIVE_UINT32, dsetu32); H5Sclose(space); H5Aclose(attr); @@ -7589,14 +7625,14 @@ gent_attr_intsize(void) valu64bits = (uint64_t)~0Lu; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu64[i][0] = valu64bits; + dsetu64->arr[i][0] = valu64bits; for (j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j - 1] << 1; + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; } valu64bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_UINT64, dsetu64[0]); + H5Awrite(attr, H5T_NATIVE_UINT64, dsetu64); H5Sclose(space); H5Aclose(attr); @@ -7608,14 +7644,14 @@ gent_attr_intsize(void) val8bits = (int8_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset8[i][0] = val8bits; + dset8->arr[i][0] = val8bits; for (j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } - H5Awrite(attr, H5T_NATIVE_INT8, dset8[0]); + H5Awrite(attr, H5T_NATIVE_INT8, dset8); H5Sclose(space); H5Aclose(attr); @@ -7627,14 +7663,14 @@ gent_attr_intsize(void) val16bits = (int16_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset16[i][0] = val16bits; + dset16->arr[i][0] = val16bits; for (j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } - H5Awrite(attr, H5T_NATIVE_INT16, dset16[0]); + H5Awrite(attr, H5T_NATIVE_INT16, dset16); H5Sclose(space); H5Aclose(attr); @@ -7646,14 +7682,14 @@ gent_attr_intsize(void) val32bits = (int32_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset32[i][0] = val32bits; + dset32->arr[i][0] = val32bits; for (j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j - 1] << 1; + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; } val32bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_INT32, dset32[0]); + H5Awrite(attr, H5T_NATIVE_INT32, dset32); H5Sclose(space); H5Aclose(attr); @@ -7665,14 +7701,14 @@ gent_attr_intsize(void) val64bits = (int64_t)~0L; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset64[i][0] = val64bits; + dset64->arr[i][0] = val64bits; for (j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j - 1] << 1; + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; } val64bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_INT64, dset64[0]); + H5Awrite(attr, H5T_NATIVE_INT64, dset64); H5Sclose(space); H5Aclose(attr); @@ -7684,9 +7720,9 @@ gent_attr_intsize(void) for (i = 0; i < dims[0]; i++) for (j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001 * (double)j + (double)i; + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; - H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl[0]); + H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl); H5Sclose(space); H5Aclose(attr); @@ -8586,15 +8622,33 @@ gent_intscalars(void) hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t ** dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t ** dset8 = NULL; - int16_t ** dset16 = NULL; - int32_t ** dset32 = NULL; - int64_t ** dset64 = NULL; - double ** dsetdbl = NULL; + struct { + uint8_t arr[F73_XDIM][F73_YDIM8]; + } * dsetu8; + struct { + uint16_t arr[F73_XDIM][F73_YDIM16]; + } * dsetu16; + struct { + uint32_t arr[F73_XDIM][F73_YDIM32]; + } * dsetu32; + struct { + uint64_t arr[F73_XDIM][F73_YDIM64]; + } * dsetu64; + struct { + int8_t arr[F73_XDIM][F73_YDIM8]; + } * dset8; + struct { + int16_t arr[F73_XDIM][F73_YDIM16]; + } * dset16; + struct { + int32_t arr[F73_XDIM][F73_YDIM32]; + } * dset32; + struct { + int64_t arr[F73_XDIM][F73_YDIM64]; + } * dset64; + struct { + double arr[F73_XDIM][F73_YDIM8]; + } * dsetdbl; uint8_t valu8bits; uint16_t valu16bits; @@ -8608,15 +8662,15 @@ gent_intscalars(void) unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); fid = H5Fcreate(FILE73, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -8629,14 +8683,14 @@ gent_intscalars(void) valu8bits = (uint8_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu8[i][0] = valu8bits; + dsetu8->arr[i][0] = valu8bits; for (j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8[0]); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); H5Sclose(space); H5Dclose(dataset); @@ -8649,14 +8703,14 @@ gent_intscalars(void) valu16bits = (uint16_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu16[i][0] = valu16bits; + dsetu16->arr[i][0] = valu16bits; for (j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16[0]); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); H5Sclose(space); H5Dclose(dataset); @@ -8669,14 +8723,14 @@ gent_intscalars(void) valu32bits = (uint32_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu32[i][0] = valu32bits; + dsetu32->arr[i][0] = valu32bits; for (j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j - 1] << 1; + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; } valu32bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32[0]); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); H5Sclose(space); H5Dclose(dataset); @@ -8689,14 +8743,14 @@ gent_intscalars(void) valu64bits = (uint64_t)~0Lu; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu64[i][0] = valu64bits; + dsetu64->arr[i][0] = valu64bits; for (j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j - 1] << 1; + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; } valu64bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64[0]); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); H5Sclose(space); H5Dclose(dataset); @@ -8709,14 +8763,14 @@ gent_intscalars(void) val8bits = (int8_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset8[i][0] = val8bits; + dset8->arr[i][0] = val8bits; for (j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8[0]); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); H5Sclose(space); H5Dclose(dataset); @@ -8729,14 +8783,14 @@ gent_intscalars(void) val16bits = (int16_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset16[i][0] = val16bits; + dset16->arr[i][0] = val16bits; for (j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16[0]); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); H5Sclose(space); H5Dclose(dataset); @@ -8749,14 +8803,14 @@ gent_intscalars(void) val32bits = (int32_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset32[i][0] = val32bits; + dset32->arr[i][0] = val32bits; for (j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j - 1] << 1; + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; } val32bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); H5Sclose(space); H5Dclose(dataset); @@ -8769,14 +8823,14 @@ gent_intscalars(void) val64bits = (int64_t)~0L; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset64[i][0] = val64bits; + dset64->arr[i][0] = val64bits; for (j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j - 1] << 1; + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; } val64bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); H5Sclose(space); H5Dclose(dataset); @@ -8789,9 +8843,9 @@ gent_intscalars(void) for (i = 0; i < dims[0]; i++) for (j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001 * (double)j + (double)i; + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); H5Sclose(space); H5Dclose(dataset); @@ -8829,15 +8883,33 @@ gent_attr_intscalars(void) hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t ** dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t ** dset8 = NULL; - int16_t ** dset16 = NULL; - int32_t ** dset32 = NULL; - int64_t ** dset64 = NULL; - double ** dsetdbl = NULL; + struct { + uint8_t arr[F73_XDIM][F73_YDIM8]; + } * dsetu8; + struct { + uint16_t arr[F73_XDIM][F73_YDIM16]; + } * dsetu16; + struct { + uint32_t arr[F73_XDIM][F73_YDIM32]; + } * dsetu32; + struct { + uint64_t arr[F73_XDIM][F73_YDIM64]; + } * dsetu64; + struct { + int8_t arr[F73_XDIM][F73_YDIM8]; + } * dset8; + struct { + int16_t arr[F73_XDIM][F73_YDIM16]; + } * dset16; + struct { + int32_t arr[F73_XDIM][F73_YDIM32]; + } * dset32; + struct { + int64_t arr[F73_XDIM][F73_YDIM64]; + } * dset64; + struct { + double arr[F73_XDIM][F73_YDIM8]; + } * dsetdbl; uint8_t valu8bits; uint16_t valu16bits; @@ -8851,15 +8923,15 @@ gent_attr_intscalars(void) unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); fid = H5Fcreate(FILE74, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); @@ -8873,14 +8945,14 @@ gent_attr_intscalars(void) valu8bits = (uint8_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu8[i][0] = valu8bits; + dsetu8->arr[i][0] = valu8bits; for (j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } - H5Awrite(attr, tid, dsetu8[0]); + H5Awrite(attr, tid, dsetu8); H5Sclose(space); H5Aclose(attr); @@ -8893,14 +8965,14 @@ gent_attr_intscalars(void) valu16bits = (uint16_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu16[i][0] = valu16bits; + dsetu16->arr[i][0] = valu16bits; for (j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } - H5Awrite(attr, tid, dsetu16[0]); + H5Awrite(attr, tid, dsetu16); H5Sclose(space); H5Aclose(attr); @@ -8913,14 +8985,14 @@ gent_attr_intscalars(void) valu32bits = (uint32_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu32[i][0] = valu32bits; + dsetu32->arr[i][0] = valu32bits; for (j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j - 1] << 1; + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; } valu32bits <<= 1; } - H5Awrite(attr, tid, dsetu32[0]); + H5Awrite(attr, tid, dsetu32); H5Sclose(space); H5Aclose(attr); @@ -8933,14 +9005,14 @@ gent_attr_intscalars(void) valu64bits = (uint64_t)~0Lu; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu64[i][0] = valu64bits; + dsetu64->arr[i][0] = valu64bits; for (j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j - 1] << 1; + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; } valu64bits <<= 1; } - H5Awrite(attr, tid, dsetu64[0]); + H5Awrite(attr, tid, dsetu64); H5Sclose(space); H5Aclose(attr); @@ -8953,14 +9025,14 @@ gent_attr_intscalars(void) val8bits = (int8_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset8[i][0] = val8bits; + dset8->arr[i][0] = val8bits; for (j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } - H5Awrite(attr, tid, dset8[0]); + H5Awrite(attr, tid, dset8); H5Sclose(space); H5Aclose(attr); @@ -8973,14 +9045,14 @@ gent_attr_intscalars(void) val16bits = (int16_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset16[i][0] = val16bits; + dset16->arr[i][0] = val16bits; for (j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } - H5Awrite(attr, tid, dset16[0]); + H5Awrite(attr, tid, dset16); H5Sclose(space); H5Aclose(attr); @@ -8993,14 +9065,14 @@ gent_attr_intscalars(void) val32bits = (int32_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset32[i][0] = val32bits; + dset32->arr[i][0] = val32bits; for (j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j - 1] << 1; + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; } val32bits <<= 1; } - H5Awrite(attr, tid, dset32[0]); + H5Awrite(attr, tid, dset32); H5Sclose(space); H5Aclose(attr); @@ -9013,14 +9085,14 @@ gent_attr_intscalars(void) val64bits = (int64_t)~0L; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset64[i][0] = val64bits; + dset64->arr[i][0] = val64bits; for (j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j - 1] << 1; + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; } val64bits <<= 1; } - H5Awrite(attr, tid, dset64[0]); + H5Awrite(attr, tid, dset64); H5Sclose(space); H5Aclose(attr); @@ -9033,9 +9105,9 @@ gent_attr_intscalars(void) for (i = 0; i < dims[0]; i++) for (j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001 * (double)j + (double)i; + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; - H5Awrite(attr, tid, dsetdbl[0]); + H5Awrite(attr, tid, dsetdbl); H5Sclose(space); H5Aclose(attr); @@ -9618,15 +9690,33 @@ gent_intattrscalars(void) hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t ** dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t ** dset8 = NULL; - int16_t ** dset16 = NULL; - int32_t ** dset32 = NULL; - int64_t ** dset64 = NULL; - double ** dsetdbl = NULL; + struct { + uint8_t arr[F73_XDIM][F73_YDIM8]; + } *dsetu8 = NULL; + struct { + uint16_t arr[F73_XDIM][F73_YDIM16]; + } *dsetu16 = NULL; + struct { + uint32_t arr[F73_XDIM][F73_YDIM32]; + } *dsetu32 = NULL; + struct { + uint64_t arr[F73_XDIM][F73_YDIM64]; + } *dsetu64 = NULL; + struct { + int8_t arr[F73_XDIM][F73_YDIM8]; + } *dset8 = NULL; + struct { + int16_t arr[F73_XDIM][F73_YDIM16]; + } *dset16 = NULL; + struct { + int32_t arr[F73_XDIM][F73_YDIM32]; + } *dset32 = NULL; + struct { + int64_t arr[F73_XDIM][F73_YDIM64]; + } *dset64 = NULL; + struct { + double arr[F73_XDIM][F73_YDIM8]; + } *dsetdbl = NULL; uint8_t valu8bits; uint16_t valu16bits; @@ -9640,15 +9730,15 @@ gent_intattrscalars(void) unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); fid = H5Fcreate(FILE78, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -9661,9 +9751,9 @@ gent_intattrscalars(void) valu8bits = (uint8_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu8[i][0] = valu8bits; + dsetu8->arr[i][0] = valu8bits; for (j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } @@ -9671,7 +9761,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); /* Attribute of 8 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu8[0]); + H5Awrite(attr, tid, dsetu8); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9685,9 +9775,9 @@ gent_intattrscalars(void) valu16bits = (uint16_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu16[i][0] = valu16bits; + dsetu16->arr[i][0] = valu16bits; for (j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } @@ -9695,7 +9785,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); /* Attribute of 16 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu16[0]); + H5Awrite(attr, tid, dsetu16); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9709,9 +9799,9 @@ gent_intattrscalars(void) valu32bits = (uint32_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu32[i][0] = valu32bits; + dsetu32->arr[i][0] = valu32bits; for (j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j - 1] << 1; + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; } valu32bits <<= 1; } @@ -9719,7 +9809,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); /* Attribute of 32 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu32[0]); + H5Awrite(attr, tid, dsetu32); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9733,9 +9823,9 @@ gent_intattrscalars(void) valu64bits = (uint64_t)~0Lu; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu64[i][0] = valu64bits; + dsetu64->arr[i][0] = valu64bits; for (j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j - 1] << 1; + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; } valu64bits <<= 1; } @@ -9743,7 +9833,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); /* Attribute of 64 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu64[0]); + H5Awrite(attr, tid, dsetu64); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9757,9 +9847,9 @@ gent_intattrscalars(void) val8bits = (int8_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset8[i][0] = val8bits; + dset8->arr[i][0] = val8bits; for (j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } @@ -9767,7 +9857,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); /* Attribute of 8 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset8[0]); + H5Awrite(attr, tid, dset8); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9781,9 +9871,9 @@ gent_intattrscalars(void) val16bits = (int16_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset16[i][0] = val16bits; + dset16->arr[i][0] = val16bits; for (j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } @@ -9791,7 +9881,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); /* Attribute of 16 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset16[0]); + H5Awrite(attr, tid, dset16); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9805,9 +9895,9 @@ gent_intattrscalars(void) val32bits = (int32_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset32[i][0] = val32bits; + dset32->arr[i][0] = val32bits; for (j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j - 1] << 1; + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; } val32bits <<= 1; } @@ -9815,7 +9905,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); /* Attribute of 32 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset32[0]); + H5Awrite(attr, tid, dset32); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9829,9 +9919,9 @@ gent_intattrscalars(void) val64bits = (int64_t)~0L; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset64[i][0] = val64bits; + dset64->arr[i][0] = val64bits; for (j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j - 1] << 1; + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; } val64bits <<= 1; } @@ -9839,7 +9929,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); /* Attribute of 64 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset64[0]); + H5Awrite(attr, tid, dset64); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9853,12 +9943,12 @@ gent_intattrscalars(void) for (i = 0; i < dims[0]; i++) for (j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001 * (double)j + (double)i; + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); /* Attribute of double */ attr = H5Acreate2(dataset, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetdbl[0]); + H5Awrite(attr, tid, dsetdbl); H5Aclose(attr); H5Sclose(space); @@ -9896,15 +9986,33 @@ gent_intsattrs(void) hid_t aspace = H5I_INVALID_HID; hsize_t dims[2], adims[1]; - uint8_t ** dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t ** dset8 = NULL; - int16_t ** dset16 = NULL; - int32_t ** dset32 = NULL; - int64_t ** dset64 = NULL; - double ** dsetdbl = NULL; + struct { + uint8_t arr[F66_XDIM][F66_YDIM8]; + } * dsetu8; + struct { + uint16_t arr[F66_XDIM][F66_YDIM16]; + } * dsetu16; + struct { + uint32_t arr[F66_XDIM][F66_YDIM32]; + } * dsetu32; + struct { + uint64_t arr[F66_XDIM][F66_YDIM64]; + } * dsetu64; + struct { + int8_t arr[F66_XDIM][F66_YDIM8]; + } * dset8; + struct { + int16_t arr[F66_XDIM][F66_YDIM16]; + } * dset16; + struct { + int32_t arr[F66_XDIM][F66_YDIM32]; + } * dset32; + struct { + int64_t arr[F66_XDIM][F66_YDIM64]; + } * dset64; + struct { + double arr[F66_XDIM][F66_YDIM8]; + } * dsetdbl; uint8_t * asetu8 = NULL; uint16_t *asetu16 = NULL; @@ -9928,15 +10036,15 @@ gent_intsattrs(void) unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + dsetu8 = malloc(sizeof(*dsetu8)); + dsetu16 = malloc(sizeof(*dsetu16)); + dsetu32 = malloc(sizeof(*dsetu32)); + dsetu64 = malloc(sizeof(*dsetu64)); + dset8 = malloc(sizeof(*dset8)); + dset16 = malloc(sizeof(*dset16)); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dsetdbl = malloc(sizeof(*dsetdbl)); asetu8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(uint8_t)); asetu16 = HDcalloc(F66_XDIM * F66_YDIM16, sizeof(uint16_t)); @@ -9958,16 +10066,16 @@ gent_intsattrs(void) valu8bits = (uint8_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu8[i][0] = valu8bits; - asetu8[i * dims[1]] = dsetu8[i][0]; + dsetu8->arr[i][0] = valu8bits; + asetu8[i * dims[1]] = dsetu8->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); - asetu8[i * dims[1] + j] = dsetu8[i][j]; + dsetu8->arr[i][j] = (uint8_t)(dsetu8->arr[i][j - 1] << 1); + asetu8[i * dims[1] + j] = dsetu8->arr[i][j]; } valu8bits = (uint8_t)(valu8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8[0]); + H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); /* Attribute of 8 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM8; aspace = H5Screate_simple(1, adims, NULL); @@ -9986,16 +10094,16 @@ gent_intsattrs(void) valu16bits = (uint16_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu16[i][0] = valu16bits; - asetu16[i * dims[1]] = dsetu16[i][0]; + dsetu16->arr[i][0] = valu16bits; + asetu16[i * dims[1]] = dsetu16->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); - asetu16[i * dims[1] + j] = dsetu16[i][j]; + dsetu16->arr[i][j] = (uint16_t)(dsetu16->arr[i][j - 1] << 1); + asetu16[i * dims[1] + j] = dsetu16->arr[i][j]; } valu16bits = (uint16_t)(valu16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16[0]); + H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); /* Attribute of 16 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM16; aspace = H5Screate_simple(1, adims, NULL); @@ -10014,16 +10122,16 @@ gent_intsattrs(void) valu32bits = (uint32_t)~0u; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu32[i][0] = valu32bits; - asetu32[i * dims[1]] = dsetu32[i][0]; + dsetu32->arr[i][0] = valu32bits; + asetu32[i * dims[1]] = dsetu32->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j - 1] << 1; - asetu32[i * dims[1] + j] = dsetu32[i][j]; + dsetu32->arr[i][j] = dsetu32->arr[i][j - 1] << 1; + asetu32[i * dims[1] + j] = dsetu32->arr[i][j]; } valu32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32[0]); + H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); /* Attribute of 32 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM32; aspace = H5Screate_simple(1, adims, NULL); @@ -10042,16 +10150,16 @@ gent_intsattrs(void) valu64bits = (uint64_t)~0Lu; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dsetu64[i][0] = valu64bits; - asetu64[i * dims[1]] = dsetu64[i][0]; + dsetu64->arr[i][0] = valu64bits; + asetu64[i * dims[1]] = dsetu64->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j - 1] << 1; - asetu64[i * dims[1] + j] = dsetu64[i][j]; + dsetu64->arr[i][j] = dsetu64->arr[i][j - 1] << 1; + asetu64[i * dims[1] + j] = dsetu64->arr[i][j]; } valu64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64[0]); + H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); /* Attribute of 64 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM64; aspace = H5Screate_simple(1, adims, NULL); @@ -10070,16 +10178,16 @@ gent_intsattrs(void) val8bits = (int8_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset8[i][0] = val8bits; - aset8[i * dims[1]] = dset8[i][0]; + dset8->arr[i][0] = val8bits; + aset8[i * dims[1]] = dset8->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); - aset8[i * dims[1] + j] = dset8[i][j]; + dset8->arr[i][j] = (int8_t)(dset8->arr[i][j - 1] << 1); + aset8[i * dims[1] + j] = dset8->arr[i][j]; } val8bits = (int8_t)(val8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8[0]); + H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); /* Attribute of 8 bits signed int */ adims[0] = F66_XDIM * F66_YDIM8; aspace = H5Screate_simple(1, adims, NULL); @@ -10098,16 +10206,16 @@ gent_intsattrs(void) val16bits = (int16_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset16[i][0] = val16bits; - aset16[i * dims[1]] = dset16[i][0]; + dset16->arr[i][0] = val16bits; + aset16[i * dims[1]] = dset16->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); - aset16[i * dims[1] + j] = dset16[i][j]; + dset16->arr[i][j] = (int16_t)(dset16->arr[i][j - 1] << 1); + aset16[i * dims[1] + j] = dset16->arr[i][j]; } val16bits = (int16_t)(val16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16[0]); + H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); /* Attribute of 16 bits signed int */ adims[0] = F66_XDIM * F66_YDIM16; aspace = H5Screate_simple(1, adims, NULL); @@ -10126,16 +10234,16 @@ gent_intsattrs(void) val32bits = (int32_t)~0; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset32[i][0] = val32bits; - aset32[i * dims[1]] = dset32[i][0]; + dset32->arr[i][0] = val32bits; + aset32[i * dims[1]] = dset32->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j - 1] << 1; - aset32[i * dims[1] + j] = dset32[i][j]; + dset32->arr[i][j] = dset32->arr[i][j - 1] << 1; + aset32[i * dims[1] + j] = dset32->arr[i][j]; } val32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); + H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); /* Attribute of 32 bits signed int */ adims[0] = F66_XDIM * F66_YDIM32; aspace = H5Screate_simple(1, adims, NULL); @@ -10154,16 +10262,16 @@ gent_intsattrs(void) val64bits = (int64_t)~0L; /* all 1s */ for (i = 0; i < dims[0]; i++) { - dset64[i][0] = val64bits; - aset64[i * dims[1]] = dset64[i][0]; + dset64->arr[i][0] = val64bits; + aset64[i * dims[1]] = dset64->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j - 1] << 1; - aset64[i * dims[1] + j] = dset64[i][j]; + dset64->arr[i][j] = dset64->arr[i][j - 1] << 1; + aset64[i * dims[1] + j] = dset64->arr[i][j]; } val64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); + H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); /* Attribute of 64 bits signed int */ adims[0] = F66_XDIM * F66_YDIM64; aspace = H5Screate_simple(1, adims, NULL); @@ -10182,11 +10290,11 @@ gent_intsattrs(void) for (i = 0; i < dims[0]; i++) for (j = 0; j < dims[1]; j++) { - dsetdbl[i][j] = 0.0001 * (double)j + (double)i; - asetdbl[i * dims[1] + j] = dsetdbl[i][j]; + dsetdbl->arr[i][j] = 0.0001 * (double)j + (double)i; + asetdbl[i * dims[1] + j] = dsetdbl->arr[i][j]; } - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); + H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); /* Attribute of double */ adims[0] = F66_XDIM * F66_YDIM8; aspace = H5Screate_simple(1, adims, NULL); @@ -10238,9 +10346,15 @@ gent_floatsattrs(void) hid_t aspace = H5I_INVALID_HID; hsize_t dims[2], adims[1]; - float ** dset32 = NULL; - double ** dset64 = NULL; - long double **dset128 = NULL; + struct { + float arr[F89_XDIM][F89_YDIM32]; + } * dset32; + struct { + double arr[F89_XDIM][F89_YDIM64]; + } * dset64; + struct { + long double arr[F89_XDIM][F89_YDIM128]; + } * dset128; float * aset32 = NULL; double * aset64 = NULL; @@ -10253,9 +10367,9 @@ gent_floatsattrs(void) unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dset32, float, F89_XDIM, F89_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, double, F89_XDIM, F89_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset128, long double, F89_XDIM, F89_YDIM128); + dset32 = malloc(sizeof(*dset32)); + dset64 = malloc(sizeof(*dset64)); + dset128 = malloc(sizeof(*dset128)); aset32 = HDcalloc(F89_XDIM * F89_YDIM32, sizeof(float)); aset64 = HDcalloc(F89_XDIM * F89_YDIM64, sizeof(double)); @@ -10277,16 +10391,16 @@ gent_floatsattrs(void) val32bits = (float)F89_YDIM32; for (i = 0; i < dims[0]; i++) { - dset32[i][0] = val32bits; - aset32[i * dims[1]] = dset32[i][0]; + dset32->arr[i][0] = val32bits; + aset32[i * dims[1]] = dset32->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dset32[i][j] = (float)(j * dims[0] + i) / (float)F89_YDIM32; - aset32[i * dims[1] + j] = dset32[i][j]; + dset32->arr[i][j] = (float)(j * dims[0] + i) / (float)F89_YDIM32; + aset32[i * dims[1] + j] = dset32->arr[i][j]; } val32bits -= (float)1; } - H5Dwrite(dataset, H5T_IEEE_F32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); + H5Dwrite(dataset, H5T_IEEE_F32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); /* Attribute of 32 bits float */ adims[0] = F89_XDIM * F89_YDIM32; aspace = H5Screate_simple(1, adims, NULL); @@ -10305,16 +10419,16 @@ gent_floatsattrs(void) val64bits = (double)F89_YDIM64; for (i = 0; i < dims[0]; i++) { - dset64[i][0] = val64bits; - aset64[i * dims[1]] = dset64[i][0]; + dset64->arr[i][0] = val64bits; + aset64[i * dims[1]] = dset64->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dset64[i][j] = (double)(j * dims[0] + i) / (double)F89_YDIM64; - aset64[i * dims[1] + j] = dset64[i][j]; + dset64->arr[i][j] = (double)(j * dims[0] + i) / (double)F89_YDIM64; + aset64[i * dims[1] + j] = dset64->arr[i][j]; } val64bits -= (double)1; } - H5Dwrite(dataset, H5T_IEEE_F64LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); + H5Dwrite(dataset, H5T_IEEE_F64LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); /* Attribute of 64 bits double */ adims[0] = F89_XDIM * F89_YDIM64; aspace = H5Screate_simple(1, adims, NULL); @@ -10333,16 +10447,16 @@ gent_floatsattrs(void) val128bits = (long double)F89_YDIM128; for (i = 0; i < dims[0]; i++) { - dset128[i][0] = val128bits; - aset128[i * dims[1]] = dset128[i][0]; + dset128->arr[i][0] = val128bits; + aset128[i * dims[1]] = dset128->arr[i][0]; for (j = 1; j < dims[1]; j++) { - dset128[i][j] = (long double)(j * dims[0] + i) / (long double)F89_YDIM128; - aset128[i * dims[1] + j] = dset128[i][j]; + dset128->arr[i][j] = (long double)(j * dims[0] + i) / (long double)F89_YDIM128; + aset128[i * dims[1] + j] = dset128->arr[i][j]; } val128bits -= (long double)1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset128[0]); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset128); /* Attribute of 128 bits long double */ adims[0] = F89_XDIM * F89_YDIM128; aspace = H5Screate_simple(1, adims, NULL); @@ -10534,13 +10648,17 @@ gent_bitnopaquefields(void) static void gent_intsfourdims(void) { - hid_t fid, dataset, space; - hsize_t dims[F81_RANK]; - uint32_t dset1[F81_ZDIM][F81_YDIM][F81_XDIM][F81_WDIM]; + hid_t fid, dataset, space; + hsize_t dims[F81_RANK]; + struct { + uint32_t arr[F81_ZDIM][F81_YDIM][F81_XDIM][F81_WDIM]; + } * dset1; unsigned int i, j, k, l; fid = H5Fcreate(FILE81, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + dset1 = malloc(sizeof(*dset1)); + /* Dataset of 32 bits unsigned int */ dims[0] = F81_ZDIM; dims[1] = F81_YDIM; @@ -10553,7 +10671,7 @@ gent_intsfourdims(void) for (j = 0; j < F81_YDIM; j++) for (k = 0; k < F81_XDIM; k++) for (l = 0; l < F81_WDIM; l++) - dset1[i][j][k][l] = + dset1->arr[i][j][k][l] = i * F81_YDIM * F81_XDIM * F81_WDIM + j * F81_XDIM * F81_WDIM + k * F81_WDIM + l; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); @@ -10561,6 +10679,7 @@ gent_intsfourdims(void) H5Dclose(dataset); H5Fclose(fid); + free(dset1); } /*------------------------------------------------------------------------- diff --git a/tools/test/h5repack/h5repacktst.c b/tools/test/h5repack/h5repacktst.c index ed3fedd..6ca33e2 100644 --- a/tools/test/h5repack/h5repacktst.c +++ b/tools/test/h5repack/h5repacktst.c @@ -2455,14 +2455,15 @@ make_szip(hid_t loc_id) unsigned szip_pixels_per_block = 8; hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int ** buf = NULL; int szip_can_encode = 0; /* Create and fill array */ - H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); if (NULL == buf) goto error; - H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); /* create a space */ if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) @@ -2486,7 +2487,7 @@ make_szip(hid_t loc_id) /* set szip data */ if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) goto error; - if (make_dset(loc_id, "dset_szip", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_szip", sid, dcpl, buf) < 0) goto error; } else @@ -2529,15 +2530,16 @@ make_deflate(hid_t loc_id) hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int ** buf = NULL; hobj_ref_t bufref[1]; /* reference */ hsize_t dims1r[1] = {1}; /* Create and fill array */ - H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); if (NULL == buf) goto error; - H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); /* create a space */ if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) @@ -2557,7 +2559,7 @@ make_deflate(hid_t loc_id) /* set deflate data */ if (H5Pset_deflate(dcpl, 9) < 0) goto error; - if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf) < 0) goto error; /* create a reference to the dataset, test second seeep of file for references */ @@ -2608,13 +2610,14 @@ make_shuffle(hid_t loc_id) hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int ** buf = NULL; /* Create and fill array */ - H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); if (NULL == buf) goto error; - H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); /* create a space */ if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) @@ -2634,7 +2637,7 @@ make_shuffle(hid_t loc_id) /* set the shuffle filter */ if (H5Pset_shuffle(dcpl) < 0) goto error; - if (make_dset(loc_id, "dset_shuffle", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_shuffle", sid, dcpl, buf) < 0) goto error; /*------------------------------------------------------------------------- @@ -2677,13 +2680,14 @@ make_fletcher32(hid_t loc_id) hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int ** buf = NULL; /* Create and fill array */ - H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); if (NULL == buf) goto error; - H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); /* create a space */ if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) @@ -2706,7 +2710,7 @@ make_fletcher32(hid_t loc_id) /* set the checksum filter */ if (H5Pset_fletcher32(dcpl) < 0) goto error; - if (make_dset(loc_id, "dset_fletcher32", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_fletcher32", sid, dcpl, buf) < 0) goto error; /*------------------------------------------------------------------------- @@ -2752,13 +2756,14 @@ make_nbit(hid_t loc_id) hid_t dxpl = H5P_DEFAULT; hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int ** buf = NULL; /* Create and fill array */ - H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); if (NULL == buf) goto error; - H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); /* create a space */ if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) @@ -2791,7 +2796,7 @@ make_nbit(hid_t loc_id) goto error; if ((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf) < 0) goto error; H5Dclose(dsid); @@ -2799,7 +2804,7 @@ make_nbit(hid_t loc_id) goto error; if ((dsid = H5Dcreate2(loc_id, "dset_int31", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf) < 0) goto error; H5Dclose(dsid); @@ -2853,13 +2858,14 @@ make_scaleoffset(hid_t loc_id) hid_t dxpl = H5P_DEFAULT; hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int ** buf = NULL; /* Create and fill array */ - H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); if (NULL == buf) goto error; - H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); /* create a space */ if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) @@ -2890,12 +2896,12 @@ make_scaleoffset(hid_t loc_id) goto error; if ((dsid = H5Dcreate2(loc_id, "dset_scaleoffset", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf) < 0) goto error; H5Dclose(dsid); if ((dsid = H5Dcreate2(loc_id, "dset_none", dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf) < 0) goto error; H5Tclose(dtid); H5Dclose(dsid); @@ -2952,16 +2958,17 @@ make_all_filters(hid_t loc_id) #endif /* H5_HAVE_FILTER_SZIP */ hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int ** buf = NULL; #if defined(H5_HAVE_FILTER_SZIP) int szip_can_encode = 0; #endif /* Create and fill array */ - H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); if (NULL == buf) goto error; - H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); /* create a space */ if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) @@ -3011,7 +3018,7 @@ make_all_filters(hid_t loc_id) goto error; #endif - if (make_dset(loc_id, "dset_all", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_all", sid, dcpl, buf) < 0) goto error; /* remove the filters from the dcpl */ @@ -3020,7 +3027,7 @@ make_all_filters(hid_t loc_id) /* set the checksum filter */ if (H5Pset_fletcher32(dcpl) < 0) goto error; - if (make_dset(loc_id, "dset_fletcher32", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_fletcher32", sid, dcpl, buf) < 0) goto error; /* Make sure encoding is enabled */ @@ -3032,7 +3039,7 @@ make_all_filters(hid_t loc_id) /* set szip data */ if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) goto error; - if (make_dset(loc_id, "dset_szip", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_szip", sid, dcpl, buf) < 0) goto error; } else { @@ -3046,7 +3053,7 @@ make_all_filters(hid_t loc_id) /* set the shuffle filter */ if (H5Pset_shuffle(dcpl) < 0) goto error; - if (make_dset(loc_id, "dset_shuffle", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_shuffle", sid, dcpl, buf) < 0) goto error; #if defined(H5_HAVE_FILTER_DEFLATE) @@ -3056,7 +3063,7 @@ make_all_filters(hid_t loc_id) /* set deflate data */ if (H5Pset_deflate(dcpl, 1) < 0) goto error; - if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf) < 0) goto error; #endif @@ -3072,7 +3079,7 @@ make_all_filters(hid_t loc_id) goto error; if ((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf) < 0) goto error; /* close */ @@ -3217,15 +3224,16 @@ make_layout(hid_t loc_id) hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int ** buf = NULL; int i; char name[16]; /* Create and fill array */ - H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + struct { + int arr[DIM1][DIM2]; + } *buf = malloc(sizeof(*buf)); if (NULL == buf) goto error; - H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); + H5TEST_FILL_2D_HEAP_ARRAY(buf, int); /*------------------------------------------------------------------------- * make several dataset with no filters @@ -3233,7 +3241,7 @@ make_layout(hid_t loc_id) */ for (i = 0; i < 4; i++) { HDsprintf(name, "dset%d", i + 1); - if (write_dset(loc_id, RANK, dims, name, H5T_NATIVE_INT, buf[0]) < 0) + if (write_dset(loc_id, RANK, dims, name, H5T_NATIVE_INT, buf) < 0) goto error; } @@ -3254,7 +3262,7 @@ make_layout(hid_t loc_id) */ if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) goto error; - if (make_dset(loc_id, "dset_compact", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_compact", sid, dcpl, buf) < 0) goto error; /*------------------------------------------------------------------------- @@ -3263,7 +3271,7 @@ make_layout(hid_t loc_id) */ if (H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) goto error; - if (make_dset(loc_id, "dset_contiguous", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_contiguous", sid, dcpl, buf) < 0) goto error; /*------------------------------------------------------------------------- @@ -3272,7 +3280,7 @@ make_layout(hid_t loc_id) */ if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; - if (make_dset(loc_id, "dset_chunk", sid, dcpl, buf[0]) < 0) + if (make_dset(loc_id, "dset_chunk", sid, dcpl, buf) < 0) goto error; /*------------------------------------------------------------------------- @@ -3329,13 +3337,13 @@ make_layout2(hid_t loc_id) hsize_t s_dims[RANK] = {S_DIM1, S_DIM2}; /* Dataspace (< 1 k) */ hsize_t chunk_dims[RANK] = {S_DIM1 / 2, S_DIM2 / 2}; /* Dimension sizes for chunks */ - int **s_buf = NULL; /* Temporary buffer */ - /* Create and fill array */ - H5TEST_ALLOCATE_2D_ARRAY(s_buf, int, S_DIM1, S_DIM2); + struct { + int arr[S_DIM1][S_DIM2]; + } *s_buf = malloc(sizeof(*s_buf)); if (NULL == s_buf) goto error; - H5TEST_FILL_2D_ARRAY(s_buf, int, S_DIM1, S_DIM2); + H5TEST_FILL_2D_HEAP_ARRAY(s_buf, int); /* Create dataspaces */ if ((s_sid = H5Screate_simple(RANK, s_dims, NULL)) < 0) @@ -3346,7 +3354,7 @@ make_layout2(hid_t loc_id) goto error; if (H5Pset_layout(contig_dcpl, H5D_CONTIGUOUS) < 0) goto error; - if (make_dset(loc_id, CONTIG_S, s_sid, contig_dcpl, s_buf[0]) < 0) + if (make_dset(loc_id, CONTIG_S, s_sid, contig_dcpl, s_buf) < 0) goto error; /* Create chunked datasets */ @@ -3354,7 +3362,7 @@ make_layout2(hid_t loc_id) goto error; if (H5Pset_chunk(chunked_dcpl, RANK, chunk_dims) < 0) goto error; - if (make_dset(loc_id, CHUNKED_S_FIX, s_sid, chunked_dcpl, s_buf[0]) < 0) + if (make_dset(loc_id, CHUNKED_S_FIX, s_sid, chunked_dcpl, s_buf) < 0) goto error; ret_value = 0; @@ -3408,19 +3416,21 @@ make_layout3(hid_t loc_id) hsize_t chunk_dims1[RANK] = {DIM1_L3 * 2, 5}; hsize_t chunk_dims2[RANK] = {SDIM1_L3 + 2, SDIM2_L3 / 2}; hsize_t chunk_dims3[RANK] = {SDIM1_L3 - 2, SDIM2_L3 / 2}; - int ** buf1 = NULL; - int ** buf2 = NULL; - /* Create and fill arrays */ - H5TEST_ALLOCATE_2D_ARRAY(buf1, int, DIM1_L3, DIM2_L3); - if (NULL == buf1) - goto error; - H5TEST_FILL_2D_ARRAY(buf1, int, DIM1_L3, DIM2_L3); + /* Create arrays */ + struct { + int arr[DIM1_L3][DIM2_L3]; + } *buf1 = malloc(sizeof(*buf1)); + struct { + int arr[SDIM1_L3][SDIM2_L3]; + } *buf2 = malloc(sizeof(*buf2)); - H5TEST_ALLOCATE_2D_ARRAY(buf2, int, SDIM1_L3, SDIM2_L3); - if (NULL == buf2) + if (NULL == buf1 || NULL == buf2) goto error; - H5TEST_FILL_2D_ARRAY(buf2, int, SDIM1_L3, SDIM2_L3); + + /* Fill arrays */ + H5TEST_FILL_2D_HEAP_ARRAY(buf1, int); + H5TEST_FILL_2D_HEAP_ARRAY(buf2, int); /*------------------------------------------------------------------------- * make chunked dataset with @@ -3438,7 +3448,7 @@ make_layout3(hid_t loc_id) if (H5Pset_chunk(dcpl1, RANK, chunk_dims1) < 0) goto error; - if (make_dset(loc_id, "chunk_unlimit1", sid1, dcpl1, buf1[0]) < 0) + if (make_dset(loc_id, "chunk_unlimit1", sid1, dcpl1, buf1) < 0) goto error; /*------------------------------------------------------------------------- @@ -3459,7 +3469,7 @@ make_layout3(hid_t loc_id) if (H5Pset_chunk(dcpl2, RANK, chunk_dims2) < 0) goto error; - if (make_dset(loc_id, "chunk_unlimit2", sid2, dcpl2, buf2[0]) < 0) + if (make_dset(loc_id, "chunk_unlimit2", sid2, dcpl2, buf2) < 0) goto error; /*------------------------------------------------------------------------- @@ -3476,7 +3486,7 @@ make_layout3(hid_t loc_id) if (H5Pset_chunk(dcpl3, RANK, chunk_dims3) < 0) goto error; - if (make_dset(loc_id, "chunk_unlimit3", sid2, dcpl3, buf2[0]) < 0) + if (make_dset(loc_id, "chunk_unlimit3", sid2, dcpl3, buf2) < 0) goto error; /*------------------------------------------------------------------------- diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c index 53fbc42..923c3f2 100644 --- a/tools/test/misc/h5clear_gentest.c +++ b/tools/test/misc/h5clear_gentest.c @@ -56,24 +56,26 @@ const char *FILENAME_ENHANCE[] = { static int gen_cache_image_file(const char *fname) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t did = -1, sid = H5I_INVALID_HID; /* Dataset ID, dataspace ID */ - hid_t fapl = H5I_INVALID_HID; /* File access property list */ - hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ - hsize_t dims[2]; /* Dimension sizes */ - hsize_t chunks[2]; /* Chunked dimension sizes */ - int i, j; /* Local index variables */ - int ** buf = NULL; /* Buffer for data to write */ - H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t did = -1, sid = H5I_INVALID_HID; /* Dataset ID, dataspace ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + hsize_t dims[2]; /* Dimension sizes */ + hsize_t chunks[2]; /* Chunked dimension sizes */ + int i, j; /* Local index variables */ + struct { + int arr[50][100]; + } * buf; /* Buffer for data to write */ + H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */ {H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; /* Create and fill array */ - H5TEST_ALLOCATE_2D_ARRAY(buf, int, 50, 100); + buf = malloc(sizeof(*buf)); if (NULL == buf) goto error; for (i = 0; i < 50; i++) for (j = 0; j < 100; j++) - buf[i][j] = i * j; + buf->arr[i][j] = i * j; /* Create a copy of file access property list */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) @@ -108,7 +110,7 @@ gen_cache_image_file(const char *fname) goto error; /* Write to the dataset */ - if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ 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) -- cgit v0.12