From a32178ba9408ceffbb1656489703885d69fb5ed0 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 16 Mar 2018 09:03:08 -0500 Subject: Fix memory leak simply by capturing allocation in var --- test/ohdr.c | 112 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 59 insertions(+), 53 deletions(-) diff --git a/test/ohdr.c b/test/ohdr.c index e886bf9..ab50a5f5 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -21,14 +21,14 @@ * This file needs to access private datatypes from the H5O package. * This file also needs to access the object header testing code. */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ #define H5O_TESTING #include "H5Opkg.h" /* * This file needs to access private datatypes from the H5G package. */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ #include "H5Gpkg.h" const char *FILENAME[] = { @@ -49,24 +49,24 @@ const char *FILENAME[] = { /* * Verify that messages are moved forward into a "continuation message": - * Create an object header with several continuation chunks - * Remove a message in the last chunk - * The remaining message(s) in the last chunk should be moved forward into the continuation message - * The process will repeat when the continuation message is big enough to hold all the - * messages in the last chunk. - * Result: the number of chunks should be reduced + * Create an object header with several continuation chunks + * Remove a message in the last chunk + * The remaining message(s) in the last chunk should be moved forward into the continuation message + * The process will repeat when the continuation message is big enough to hold all the + * messages in the last chunk. + * Result: the number of chunks should be reduced */ static herr_t test_cont(char *filename, hid_t fapl) { - hid_t file=-1; - H5F_t *f = NULL; + hid_t file=-1; + H5F_t *f = NULL; H5O_hdr_info_t hdr_info; - H5O_loc_t oh_locA, oh_locB; - time_t time_new; - const char *short_name = "T"; - const char *long_name = "This is the message"; - size_t nchunks; + H5O_loc_t oh_locA, oh_locB; + time_t time_new; + const char *short_name = "T"; + const char *long_name = "This is the message"; + size_t nchunks; TESTING("object header continuation block"); @@ -167,15 +167,15 @@ error: static herr_t test_ohdr_cache(char *filename, hid_t fapl) { - hid_t file = -1; /* File ID */ + hid_t file = -1; /* File ID */ hid_t my_fapl; /* FAPL ID */ hid_t my_dxpl; /* DXPL ID */ H5AC_cache_config_t mdc_config; /* Metadata cache configuration info */ - H5F_t *f = NULL; /* File handle */ + H5F_t *f = NULL; /* File handle */ H5HL_t *lheap, *lheap2, *lheap3; /* Pointer to local heaps */ haddr_t lheap_addr, lheap_addr2, lheap_addr3; /* Local heap addresses */ - H5O_loc_t oh_loc; /* Object header location */ - time_t time_new; /* Time value for modification time message */ + H5O_loc_t oh_loc; /* Object header location */ + time_t time_new; /* Time value for modification time message */ unsigned rc; /* Refcount for object */ TESTING("object header creation in cache"); @@ -309,17 +309,17 @@ error: static herr_t test_ohdr_swmr(hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t did = -1; /* Dataset ID */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t did = -1; /* Dataset ID */ hid_t sid = -1; /* Dataspace ID */ - hid_t plist = -1; /* Dataset creation property list */ - size_t compact_size = 1024; /* The size of compact dataset */ - int *wbuf = NULL; /* Buffer for writing */ - hsize_t dims[1]; /* Dimension sizes */ - size_t u; /* Iterator */ + hid_t plist = -1; /* Dataset creation property list */ + size_t compact_size = 1024; /* The size of compact dataset */ + int *wbuf = NULL; /* Buffer for writing */ + hsize_t dims[1]; /* Dimension sizes */ + size_t u; /* Iterator */ int n; /* Data variable */ - H5O_info_t obj_info; /* Information for the object */ + H5O_info_t obj_info; /* Information for the object */ if(new_format) { TESTING("exercise the coding for the re-read of the object header for SWMR access: latest-format"); @@ -355,7 +355,7 @@ test_ohdr_swmr(hbool_t new_format) dims[0] = (hsize_t)compact_size; if((sid = H5Screate_simple(1, dims, NULL)) < 0) FAIL_STACK_ERROR - + /* Create property list for compact dataset creation */ if((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR @@ -448,10 +448,10 @@ error: /* * To test objects with unknown messages in a file with: - * a) H5O_BOGUS_VALID_ID: - * --the bogus_id is within the range of H5O_msg_class_g[] - * b) H5O_BOGUS_INVALID_ID: - * --the bogus_id is outside the range of H5O_msg_class_g[] + * a) H5O_BOGUS_VALID_ID: + * --the bogus_id is within the range of H5O_msg_class_g[] + * b) H5O_BOGUS_INVALID_ID: + * --the bogus_id is outside the range of H5O_msg_class_g[] * * The test file is FILE_BOGUS: "tbogus.h5" generated with gen_bogus.c * --objects that have unknown header messages with H5O_BOGUS_VALID_ID in "/" @@ -462,15 +462,15 @@ error: static herr_t test_unknown(unsigned bogus_id, char *filename, hid_t fapl) { - hid_t fid = -1; /* file ID */ - hid_t gid = -1; /* group ID */ - hid_t did = -1; /* Dataset ID */ + hid_t fid = -1; /* file ID */ + hid_t gid = -1; /* group ID */ + hid_t did = -1; /* Dataset ID */ hid_t sid = -1; /* Dataspace ID */ hid_t aid = -1; /* Attribute ID */ - hid_t loc = -1; /* location: file or group ID */ - hid_t fid_bogus = -1; /* bogus file ID */ - hid_t gid_bogus = -1; /* bogus group ID */ - hid_t loc_bogus = -1; /* location: bogus file or group ID */ + hid_t loc = -1; /* location: file or group ID */ + hid_t fid_bogus = -1; /* bogus file ID */ + hid_t gid_bogus = -1; /* bogus group ID */ + hid_t loc_bogus = -1; /* location: bogus file or group ID */ char testfile[256]; /* create a different name for a local copy of the data file to be @@ -497,7 +497,7 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Set up location ID depending on bogus_id */ if(bogus_id == H5O_BOGUS_INVALID_ID) { /* Open "group" in FILE_BOGUS */ - if((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) + if((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc_bogus = gid_bogus; @@ -562,7 +562,7 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Set up location ID depending on bogus_id */ if(bogus_id == H5O_BOGUS_INVALID_ID) { /* Open "group" in filename */ - if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) + if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc = gid; } else @@ -596,7 +596,7 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Set up location ID depending on bogus_id */ if(bogus_id == H5O_BOGUS_INVALID_ID) { /* Open "group" in filename */ - if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) + if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc = gid; } else @@ -642,7 +642,7 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Set up location ID depending on bogus_id */ if(bogus_id == H5O_BOGUS_INVALID_ID) { /* Open "group" in filename */ - if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) + if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc = gid; } else @@ -660,7 +660,7 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) if(H5Dclose(did) < 0) FAIL_STACK_ERROR - /* Closing: filename */ + /* Closing: filename */ if(bogus_id == H5O_BOGUS_INVALID_ID) if(H5Gclose(gid) < 0) FAIL_STACK_ERROR @@ -685,7 +685,7 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Set up location ID */ if(bogus_id == H5O_BOGUS_INVALID_ID) { /* Open "group" in FILE_BOGUS */ - if((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) + if((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc_bogus = gid_bogus; } else @@ -716,7 +716,7 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Closing: FILE_BOGUS */ if(bogus_id == H5O_BOGUS_INVALID_ID) if(H5Gclose(gid_bogus) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Fclose(fid_bogus) < 0) FAIL_STACK_ERROR @@ -772,21 +772,21 @@ char *version_string(H5F_libver_t libver) sprintf(str, "%ld", (long)libver); break; } /* end switch */ - + /* Return the formed version bound string */ return(str); } /* end of version_string */ - + /*------------------------------------------------------------------------- - * Function: main + * Function: main * * Purpose: Exercise private object header behavior and routines * * Return: Success: 0 * Failure: 1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, November 24, 1998 * * Modification: @@ -819,6 +819,8 @@ main(void) /* Loop through all the combinations of low/high library format bounds */ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char *low_string = NULL; + char *high_string = NULL; /* Set version bounds before opening the file */ H5E_BEGIN_TRY { @@ -829,9 +831,13 @@ main(void) continue; /* Display info about testing */ - sprintf(msg, "Using file format version: (%s, %s)", version_string(low), - version_string(high)); + low_string = version_string(low); + high_string = version_string(high); + sprintf(msg, "Using file format version: (%s, %s)", low_string, + high_string); HDputs(msg); + HDfree(high_string); + HDfree(low_string); /* test on object continuation block */ if(test_cont(filename, fapl) < 0) -- cgit v0.12 From dda1e103a527eeb747ce6fba9aefe14c11d799c5 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Fri, 16 Mar 2018 10:42:33 -0500 Subject: Fixed HDFFV-10151 Description: Added a document to the HDF5 C++ API Reference Manual to show the mapping from a C API to C++ wrappers. --- release_docs/RELEASE.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index e6fd8d3..caf53fc 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -231,6 +231,12 @@ New Features (BMR - 2018/03/11, HDFFV-10149) + - A document is added to the HDF5 C++ API Reference Manual to show the + mapping from a C API to C++ wrappers. It can be found from the main + page of the C++ API Reference Manual. + + (BMR - 2017/10/17, HDFFV-10151) + Java Library: ---------------- -- cgit v0.12 From 6fac268a7e1ee5b6d5314f40ac45630d9c67d873 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Sat, 17 Mar 2018 10:19:22 -0500 Subject: Updated RELEASE.txt Description: Wrappers for H5Tencode and H5Tdecode No code change. --- release_docs/RELEASE.txt | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index caf53fc..e18b43a 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -174,8 +174,7 @@ New Features C++ Library: ------------ - - The following wrappers are added: - + - The following C++ API wrappers have been added to the C++ Library: + H5Lcreate_soft: // Creates a soft link from link_name to target_name. void link(const char *target_name, const char *link_name,...) @@ -219,15 +218,37 @@ New Features void unlink(const H5std_string& link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) - - Added class LinkCreatPropList + Note: additional parameter is added to previous H5Location::unlink. + + + H5Tencode and H5Tdecode: + // Creates a binary object description of this datatype. + void DataType::encode() - C API H5Tencode() + + // Returns the decoded type from the binary object description. + DataType::decode() - C API H5Tdecode() + ArrayType::decode() - C API H5Tdecode() + CompType::decode() - C API H5Tdecode() + DataType::decode() - C API H5Tdecode() + EnumType::decode() - C API H5Tdecode() + FloatType::decode() - C API H5Tdecode() + IntType::decode() - C API H5Tdecode() + StrType::decode() - C API H5Tdecode() + VarLenType::decode() - C API H5Tdecode() + + + H5Lget_info: + // Returns the information of the named link. + H5L_info_t getLinkInfo(const H5std_string& link_name,...) + + (BMR - 2018/03/11, HDFFV-10149) + + - Added class LinkCreatPropList for link create property list. + + (BMR - 2018/03/11, HDFFV-10149) - Added overloaded functions H5Location::createGroup to take a link creation property list Group createGroup(const char* name, const LinkCreatPropList& lcpl) Group createGroup(const H5std_string& name, const LinkCreatPropList& lcpl) - - Added wrapper for H5Lget_info() to H5Location - // Returns the information of the named link. - H5L_info_t getLinkInfo(const H5std_string& link_name,...) (BMR - 2018/03/11, HDFFV-10149) -- cgit v0.12