diff options
author | jhendersonHDF <jhenderson@hdfgroup.org> | 2024-03-10 07:47:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-10 07:47:31 (GMT) |
commit | ef401a5f5edf2fc689334a485a6c2ec3f53ecb85 (patch) | |
tree | 4807deea31bdb83a5f3903f9dc3fddd48a1e0785 /tools/test/h5format_convert | |
parent | 28aaeb967ce66477441dc1f92fc45dddb51255c2 (diff) | |
download | hdf5-ef401a5f5edf2fc689334a485a6c2ec3f53ecb85.zip hdf5-ef401a5f5edf2fc689334a485a6c2ec3f53ecb85.tar.gz hdf5-ef401a5f5edf2fc689334a485a6c2ec3f53ecb85.tar.bz2 |
Refactor datatype conversion code to use pointers rather than IDs (#4104)
The datatype conversion code previously used IDs for the source and
destination datatypes rather than pointers to the internal structures
for those datatypes. This was mostly due to the need for an ID for these
datatypes that can be passed to an application-registered datatype
conversion function or datatype conversion exception function. However,
using IDs internally caused a lot of unnecessary ID lookups and hurt
performance of datatype conversions in general. This was especially
problematic for compound datatype conversions, where the ID lookups were
occuring on every member of every compound element of a dataset. The
code has now been refactored to use pointers internally and only create
IDs for datatypes when necessary.
Fixed a test issue in dt_arith where a library datatype conversion
function was being cast to an application conversion function. Since the
two have different prototypes, this started failing after the parameters
for a library conversion function changed from hid_t to H5T_t * and an
extra parameter was added. This appears to have worked coincidentally in
the past since the only different between a library conversion function
and application conversion function was an extra DXPL parameter at the
end of an application conversion function
Fixed an issue where memory wasn't being freed in the h5fc_chk_idx test
program. Even though the program exits quickly after allocating the
memory, it still causes failures when testing with -fsanitize=address
Diffstat (limited to 'tools/test/h5format_convert')
-rw-r--r-- | tools/test/h5format_convert/h5fc_chk_idx.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/tools/test/h5format_convert/h5fc_chk_idx.c b/tools/test/h5format_convert/h5fc_chk_idx.c index 7adc33d..24434b0 100644 --- a/tools/test/h5format_convert/h5fc_chk_idx.c +++ b/tools/test/h5format_convert/h5fc_chk_idx.c @@ -61,39 +61,47 @@ main(int argc, char *argv[]) /* Try opening the file */ if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, false, NULL, (size_t)0)) < 0) { fprintf(stderr, "h5fc_chk_idx: unable to open the file\n"); - exit(EXIT_FAILURE); + goto error; } /* end if */ /* Open the dataset */ if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) { fprintf(stderr, "h5fc_chk_idx: unable to open the dataset\n"); - exit(EXIT_FAILURE); + goto error; } /* end if */ /* Get the dataset's chunk indexing type */ if (H5Dget_chunk_index_type(did, &idx_type) < 0) { fprintf(stderr, "h5fc_chk_idx: unable to get chunk index type for the dataset\n"); - exit(EXIT_FAILURE); + goto error; } /* end if */ /* Close the dataset */ if (H5Dclose(did) < 0) { fprintf(stderr, "h5fc_chk_idx: unable to close the dataset\n"); - exit(EXIT_FAILURE); + goto error; } /* end if */ /* Close the file */ if (H5Fclose(fid) < 0) { fprintf(stderr, "h5fc_chk_idx_type: cannot close the file\n"); - exit(EXIT_FAILURE); + goto error; } /* end if */ /* Return success when the chunk indexing type is version 1 B-tree */ - if (idx_type == H5D_CHUNK_IDX_BTREE) - exit(EXIT_SUCCESS); - else { + if (idx_type != H5D_CHUNK_IDX_BTREE) { fprintf(stderr, "Error: chunk indexing type is %d\n", idx_type); - exit(EXIT_FAILURE); + goto error; } /* end if */ + free(fname); + free(dname); + + exit(EXIT_SUCCESS); + +error: + free(fname); + free(dname); + + exit(EXIT_FAILURE); } /* main() */ |