diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2015-10-11 04:05:21 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2015-10-11 04:05:21 (GMT) |
commit | fc84edb7e3514556e1b5cbd5268d35fcf21054b6 (patch) | |
tree | 06d36bc6f55016fc2be2dffe019a7c16f094da7e /c++/src/H5File.cpp | |
parent | cd49e8a2abcd1a6fd1a4ac578cc208e2bbad1914 (diff) | |
download | hdf5-fc84edb7e3514556e1b5cbd5268d35fcf21054b6.zip hdf5-fc84edb7e3514556e1b5cbd5268d35fcf21054b6.tar.gz hdf5-fc84edb7e3514556e1b5cbd5268d35fcf21054b6.tar.bz2 |
[svn-r28027] Purpose: Fix memory leaks
Description:
- Removed H5Library::instance because it is unnecessary. All H5Library's
methods are static. This, in turn, removed the memory leaks by
H5Library::instance not being deleted.
- Added ObjCreatPropList::deleteConstants to atexist() list
- Cleaned up comments and format inconsistencies with 1.8
Platforms tested:
Linux/32 2.6 (jam)
Linux/64 (platypus)
Darwin (osx1010test)
Diffstat (limited to 'c++/src/H5File.cpp')
-rw-r--r-- | c++/src/H5File.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 44fc53c..b169472 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -133,28 +133,26 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro // create the file. if( flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)) { - hid_t create_plist_id = create_plist.getId(); - hid_t access_plist_id = access_plist.getId(); - id = H5Fcreate( name, flags, create_plist_id, access_plist_id ); - if( id < 0 ) // throw an exception when open/create fail - { - throw FileIException("H5File constructor", "H5Fcreate failed"); - } + hid_t create_plist_id = create_plist.getId(); + hid_t access_plist_id = access_plist.getId(); + id = H5Fcreate( name, flags, create_plist_id, access_plist_id ); + if( id < 0 ) // throw an exception when open/create fail + { + throw FileIException("H5File constructor", "H5Fcreate failed"); + } } // Open the file if none of the bits above are set. else { - hid_t access_plist_id = access_plist.getId(); - id = H5Fopen( name, flags, access_plist_id ); - if( id < 0 ) // throw an exception when open/create fail - { - throw FileIException("H5File constructor", "H5Fopen failed"); - } + hid_t access_plist_id = access_plist.getId(); + id = H5Fopen( name, flags, access_plist_id ); + if( id < 0 ) // throw an exception when open/create fail + { + throw FileIException("H5File constructor", "H5Fopen failed"); + } } } -#endif // DOXYGEN_SHOULD_SKIP_THIS - //-------------------------------------------------------------------------- // Function: H5File overloaded constructor ///\brief Creates an H5File object using an existing file id. @@ -174,6 +172,8 @@ H5File::H5File(hid_t existing_id) : H5Location(), CommonFG() incRefCount(); // increment number of references to this id } +#endif // DOXYGEN_SHOULD_SKIP_THIS + //-------------------------------------------------------------------------- // Function: H5File copy constructor ///\brief Copy constructor: makes a copy of the original @@ -523,16 +523,16 @@ hsize_t H5File::getFileSize() const } //-------------------------------------------------------------------------- -// Function: H5File::getId +// Function: H5File::getId ///\brief Get the id of this file ///\return File identifier // Modification: -// May 2008 - BMR -// Class hierarchy is revised to address bugzilla 1068. Class -// AbstractDS and Attribute are moved out of H5Object. In -// addition, member IdComponent::id is moved into subclasses, and -// IdComponent::getId now becomes pure virtual function. -// Programmer Binh-Minh Ribler - May, 2008 +// May 2008 - BMR +// Class hierarchy is revised to address bugzilla 1068. Class +// AbstractDS and Attribute are moved out of H5Object. In +// addition, member IdComponent::id is moved into subclasses, and +// IdComponent::getId now becomes pure virtual function. +// Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- hid_t H5File::getId() const { @@ -541,42 +541,42 @@ hid_t H5File::getId() const #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5File::getLocId -// Purpose: Get the id of this file +// Function: H5File::reopen +// Purpose: Reopens this file. +// Exception H5::FileIException // Description -// This function is a redefinition of CommonFG::getLocId. It -// is used by CommonFG member functions to get the file id. +// This function is replaced by the above function reOpen. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hid_t H5File::getLocId() const +void H5File::reopen() { - return( getId() ); + H5File::reOpen(); } //-------------------------------------------------------------------------- -// Function: H5File::reopen -// Purpose: Reopens this file. -// Exception H5::FileIException +// Function: H5File::getLocId +// Purpose: Get the id of this file // Description -// This function is replaced by the above function reOpen. +// This function is a redefinition of CommonFG::getLocId. It +// is used by CommonFG member functions to get the file id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5File::reopen() +hid_t H5File::getLocId() const { - H5File::reOpen(); + return( getId() ); } //-------------------------------------------------------------------------- -// Function: H5File::p_setId (protected) -///\brief Sets the identifier of this object to a new value. +// Function: H5File::p_setId (protected) +///\brief Sets the identifier of this object to a new value. /// -///\exception H5::IdComponentException when the attempt to close the HDF5 -/// object fails +///\exception H5::IdComponentException when the attempt to close the HDF5 +/// object fails // Description: -// The underlaying reference counting in the C library ensures -// that the current valid id of this object is properly closed. -// Then the object's id is reset to the new id. -// Programmer Binh-Minh Ribler - 2000 +// The underlaying reference counting in the C library ensures +// that the current valid id of this object is properly closed. +// Then the object's id is reset to the new id. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5File::p_setId(const hid_t new_id) { |