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 | |
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)
-rw-r--r-- | c++/src/H5AbstractDs.h | 4 | ||||
-rw-r--r-- | c++/src/H5Attribute.h | 2 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5DataType.h | 3 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5DxferProp.h | 4 | ||||
-rw-r--r-- | c++/src/H5Exception.cpp | 6 | ||||
-rw-r--r-- | c++/src/H5Exception.h | 4 | ||||
-rw-r--r-- | c++/src/H5FaccProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 84 | ||||
-rw-r--r-- | c++/src/H5FloatType.h | 8 | ||||
-rw-r--r-- | c++/src/H5IdComponent.cpp | 16 | ||||
-rw-r--r-- | c++/src/H5IdComponent.h | 36 | ||||
-rw-r--r-- | c++/src/H5Library.cpp | 72 | ||||
-rw-r--r-- | c++/src/H5Library.h | 10 |
15 files changed, 134 insertions, 125 deletions
diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 810dc8b..ee2e45e 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -68,7 +68,7 @@ class H5_DLLCPP AbstractDs { ///\brief Returns the amount of storage size required - pure virtual. virtual hsize_t getStorageSize() const = 0; - ///\brief Returns this class name. + // Returns this class name - pure virtual. virtual H5std_string fromClass() const = 0; // Destructor @@ -91,7 +91,7 @@ class H5_DLLCPP AbstractDs { // AbstractDs( const AbstractDs& original ); private: - // This member function is implemented by DataSet and Attribute. + // This member function is implemented by DataSet and Attribute - pure virtual. virtual hid_t p_get_type() const = 0; }; #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index eced64e..f5ee4a9 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -86,8 +86,8 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent { // Destructor: properly terminates access to this attribute. virtual ~Attribute(); - protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS + protected: // Sets the attribute id. virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 88dff89..b352f2d 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -144,10 +144,10 @@ DataType::DataType(const DataType& original) : H5Object() //-------------------------------------------------------------------------- // Function: DataType overloaded constructor -///\brief Creates a integer type using a predefined type +///\brief Creates a DataType instance using a predefined type ///\param pred_type - IN: Predefined datatype ///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2015 // Description // Copying the type so that when a predefined type is passed in, // a copy of it is made, not just a duplicate of the HDF5 id. diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index 6c8a312..5705b83 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -14,6 +14,9 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +// Class DataType inherits from H5Object and has several subclasses for +// specific HDF5 data types. + #ifndef __H5DataType_H #define __H5DataType_H diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index ebdadc4..792956a 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -14,6 +14,9 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +// Class DSetCreatPropList represents the HDF5 dataset creation property list +// and inherits from PropList. + #ifndef __H5DSCreatPropList_H #define __H5DSCreatPropList_H diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index 85d2ec2..52a9a48 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -14,6 +14,9 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +// Class DSetMemXferPropList represents the HDF5 dataset transfer property list +// and inherits from PropList. + #ifndef __H5DSetMemXferPropList_H #define __H5DSetMemXferPropList_H @@ -132,4 +135,3 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { } #endif #endif // __H5DSetMemXferPropList_H - diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index fb1e42e..1ca059b 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -309,9 +309,9 @@ const char* Exception::getCFuncName() const //-------------------------------------------------------------------------- void Exception::printErrorStack(FILE* stream, hid_t err_stack) { - herr_t ret_value = H5Eprint2(err_stack, stream); - if( ret_value < 0 ) - throw Exception( "Printing error stack", "H5Eprint2 failed" ); + herr_t ret_value = H5Eprint2(err_stack, stream); + if( ret_value < 0 ) + throw Exception( "Printing error stack", "H5Eprint2 failed" ); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 639b633..d49c19a 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -86,8 +86,8 @@ class H5_DLLCPP Exception { virtual ~Exception() throw(); protected: - // Default value for detail_message - static const char DEFAULT_MSG[]; + // Default value for detail_message + static const char DEFAULT_MSG[]; private: H5std_string detail_message; diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index 7d6529e..b214447 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -14,6 +14,9 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +// Class FileAccPropList represents the HDF5 file access property list and +// inherits from DataType. + #ifndef __H5FileAccPropList_H #define __H5FileAccPropList_H 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) { diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index 06a5450..e88093e 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -24,10 +24,10 @@ namespace H5 { //! Class FloatType operates on HDF5 floating point datatype. class H5_DLLCPP FloatType : public AtomType { public: - // Creates a floating-point type using a predefined type - FloatType( const PredType& pred_type ); + // Creates a floating-point type using a predefined type. + FloatType( const PredType& pred_type ); - // Gets the floating-point datatype of the specified dataset + // Gets the floating-point datatype of the specified dataset. FloatType( const DataSet& dataset ); // Retrieves the exponent bias of a floating-point type. @@ -60,7 +60,7 @@ class H5_DLLCPP FloatType : public AtomType { // Default constructor FloatType(); - // Creates a floating-point datatype using an existing id + // Creates a floating-point datatype using an existing id. FloatType( const hid_t existing_id ); // Copy constructor: makes a copy of the original FloatType object. diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 93ee4fd..19d68cf 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -26,14 +26,19 @@ namespace H5 { #endif -// This flag controls whether H5Library::initH5cpp has been called to register -// terminating functions with atexit() +// This flag indicates whether H5Library::initH5cpp has been called to register +// the terminating functions with atexit() bool IdComponent::H5cppinit = false; + +// This flag is used to decide whether H5dont_atexit should be called. +// Subclasses that have global constants use it. This is a temporary +// work-around in 1.8.16. It will be removed after HDFFV-9540 is fixed. bool IdComponent::H5dontAtexit_called = false; //-------------------------------------------------------------------------- // Function: IdComponent overloaded constructor -// Purpose Creates an IdComponent object using the id of an existing object. +///\brief Creates an IdComponent object using the id of an existing +/// object. - Obsolete, will be removed in 1.8.17 // Param h5_id - IN: Id of an existing object // Exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 @@ -43,7 +48,6 @@ bool IdComponent::H5dontAtexit_called = false; // been moved to the sub-classes. It will be removed in 1.10 release. If its // removal does not raise any problems in 1.10, it will be removed from 1.8 in // subsequent releases. -// - Removed from documentation in 1.8.16 -BMR (October 2015) //-------------------------------------------------------------------------- IdComponent::IdComponent(const hid_t h5_id) {} @@ -295,10 +299,10 @@ H5std_string IdComponent::inMemFunc(const char* func_name) const IdComponent::IdComponent() { // initH5cpp will register the terminating functions with atexit(). - // We only do this once. + // This should only be done once. if (!H5cppinit) { - H5Library::getInstance()->initH5cpp(); + H5Library::initH5cpp(); H5cppinit = true; } } diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index 1c29f09..61c8bd6 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -17,6 +17,8 @@ #ifndef __IdComponent_H #define __IdComponent_H +// IdComponent represents an HDF5 object that has an identifier. + #ifndef H5_NO_NAMESPACE namespace H5 { #endif @@ -30,12 +32,7 @@ class DataSpace; rarely needs them. */ class H5_DLLCPP IdComponent { - public: - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - static bool H5cppinit; - static bool H5dontAtexit_called; -#endif // DOXYGEN_SHOULD_SKIP_THIS + public: // Increment reference counter. void incRefCount(const hid_t obj_id) const; @@ -58,11 +55,6 @@ class H5_DLLCPP IdComponent { // Assignment operator. IdComponent& operator=( const IdComponent& rhs ); -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Gets the identifier of this object. - virtual hid_t getId () const = 0; -#endif // DOXYGEN_SHOULD_SKIP_THIS - // Sets the identifier of this object to a new value. void setId(const hid_t new_id); @@ -76,10 +68,14 @@ class H5_DLLCPP IdComponent { // Creates an object to hold an HDF5 identifier. IdComponent( const hid_t h5_id ); +#ifndef DOXYGEN_SHOULD_SKIP_THIS + // Copy constructor: makes copy of the original IdComponent object. - // IdComponent( const IdComponent& original ); + // IdComponent( const IdComponent& original ); - removed from 1.8.15 + + // Gets the identifier of this object. + virtual hid_t getId () const = 0; -#ifndef DOXYGEN_SHOULD_SKIP_THIS // Pure virtual function for there are various H5*close for the // subclasses. virtual void close() = 0; @@ -96,11 +92,12 @@ class H5_DLLCPP IdComponent { // Destructor virtual ~IdComponent(); - protected: +#ifndef DOXYGEN_SHOULD_SKIP_THIS + + protected: // Default constructor. IdComponent(); -#ifndef DOXYGEN_SHOULD_SKIP_THIS // Gets the name of the file, in which an HDF5 object belongs. H5std_string p_get_file_name() const; @@ -110,7 +107,14 @@ class H5_DLLCPP IdComponent { // Sets the identifier of this object to a new value. - this one // doesn't increment reference count virtual void p_setId(const hid_t new_id) = 0; - //virtual void p_setId(const hid_t new_id); + + // This flag is used to decide whether H5dont_atexit should be called + static bool H5dontAtexit_called; + + private: + // This flag indicates whether H5Library::initH5cpp has been called + // to register various terminating functions with atexit() + static bool H5cppinit; #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index e7e9fb6..40c766a 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -38,11 +38,14 @@ namespace H5 { #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS -H5Library* H5Library::instance = 0; + +// This static variable is unused, will be removed in future releases. +bool H5Library::need_cleanup = false; + #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Library::open +// Function: H5Library::open (static) ///\brief Initializes the HDF5 library. /// ///\exception H5::LibraryIException @@ -58,7 +61,7 @@ void H5Library::open() } //-------------------------------------------------------------------------- -// Function: H5Library::close +// Function: H5Library::close (static) ///\brief Flushes all data to disk, closes files, and cleans up memory. /// ///\exception H5::LibraryIException @@ -74,7 +77,7 @@ void H5Library::close() } //-------------------------------------------------------------------------- -// Function: H5Library::dontAtExit +// Function: H5Library::dontAtExit (static) ///\brief Instructs library not to install the C \c atexit cleanup routine /// ///\exception H5::LibraryIException @@ -89,7 +92,7 @@ void H5Library::dontAtExit() } //-------------------------------------------------------------------------- -// Function: H5Library::getLibVersion +// Function: H5Library::getLibVersion (static) ///\brief Returns the HDF library release number. ///\param majnum - OUT: Major version of the library ///\param minnum - OUT: Minor version of the library @@ -107,7 +110,7 @@ void H5Library::getLibVersion( unsigned& majnum, unsigned& minnum, unsigned& rel } //-------------------------------------------------------------------------- -// Function: H5Library::checkVersion +// Function: H5Library::checkVersion (static) ///\brief Verifies that the arguments match the version numbers /// compiled into the library ///\param majnum - IN: Major version of the library @@ -130,7 +133,7 @@ void H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) } //-------------------------------------------------------------------------- -// Function: H5Library::garbageCollect +// Function: H5Library::garbageCollect (static) ///\brief Walks through all the garbage collection routines for the /// library, which are supposed to free any unused memory they /// have allocated. @@ -159,7 +162,7 @@ void H5Library::garbageCollect() } //-------------------------------------------------------------------------- -// Function: H5Library::initH5cpp +// Function: H5Library::initH5cpp (static) ///\brief Initializes C++ library and registers terminating functions at /// exit. Only for the library functions, not for user-defined /// functions. @@ -167,52 +170,56 @@ void H5Library::garbageCollect() // initH5cpp registers the following functions with std::atexit(): // termH5cpp() - calls H5close() after all cleanup in // the C++ library is done -// <classname>::deleteConstants - deletes all references for -// <classname> global constants +// <classname>::deleteConstants - deletes all references +// for <classname> global constants ///\exception H5::LibraryIException // // Programmer Binh-Minh Ribler - September, 2015 //-------------------------------------------------------------------------- void H5Library::initH5cpp() { - // Register terminating functions with atexit(); they will be invoked in the - // reversed order + // Register terminating functions with atexit(); they will be invoked in + // the reversed order int ret_value = 0; ret_value = std::atexit(termH5cpp); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of termH5cpp failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating termH5cpp failed"); ret_value = std::atexit(PredType::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of PredType::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating PredType::deleteConstants failed"); ret_value = std::atexit(PropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of PropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating PropList::deleteConstants failed"); ret_value = std::atexit(FileAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of FileAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating FileAccPropList::deleteConstants failed"); ret_value = std::atexit(FileCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of FileCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating FileCreatPropList::deleteConstants failed"); ret_value = std::atexit(DSetMemXferPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of DSetMemXferPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating DSetMemXferPropList::deleteConstants failed"); ret_value = std::atexit(DSetCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of DSetCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating DSetCreatPropList::deleteConstants failed"); + + ret_value = std::atexit(ObjCreatPropList::deleteConstants); + if (ret_value != 0) + throw LibraryIException("H5Library::initH5cpp", "Registrating ObjCreatPropList::deleteConstants failed"); ret_value = std::atexit(DataSpace::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of DataSpace::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating DataSpace::deleteConstants failed"); } //-------------------------------------------------------------------------- -// Function: H5Library::termH5cpp +// Function: H5Library::termH5cpp (static) ///\brief Sends request for the C layer to terminate. ///\par Description /// If the C library fails to terminate, exit with a failure. @@ -227,24 +234,7 @@ void H5Library::termH5cpp() } //-------------------------------------------------------------------------- -// Function: H5Library::getInstance -///\brief Provides a way to instantiate the class. -///\par Description -/// getInstance ensures that only one instance of the H5Library -/// is created. -// Programmer Binh-Minh Ribler - September, 2015 -//-------------------------------------------------------------------------- -H5Library* H5Library::getInstance() -{ - if (H5Library::instance == 0) - { - instance = new H5Library(); - } - return(instance); -} - -//-------------------------------------------------------------------------- -// Function: H5Library::setFreeListLimits +// Function: H5Library::setFreeListLimits (static) ///\brief Sets limits on the different kinds of free lists. ///\param reg_global_lim - IN: Limit on all "regular" free list memory used ///\param reg_list_lim - IN: Limit on memory used in each "regular" free list @@ -271,10 +261,10 @@ void H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, } } -// Default constructor - no instance ever created by outsiders +// Default constructor - private H5Library::H5Library(){}; -// Destructor +// Destructor - private H5Library::~H5Library(){}; #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index 68ab039..336f9c8 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -29,6 +29,11 @@ namespace H5 { */ class H5_DLLCPP H5Library { public: +#ifndef DOXYGEN_SHOULD_SKIP_THIS + static bool need_cleanup; // indicates if H5close should be called + // - unused, will be removed in future releases. +#endif // DOXYGEN_SHOULD_SKIP_THIS + // Initializes the HDF5 library. static void open(); @@ -60,15 +65,10 @@ class H5_DLLCPP H5Library { // Sends request for terminating the HDF5 library. static void termH5cpp(void); - static H5Library* getInstance(); - #ifndef DOXYGEN_SHOULD_SKIP_THIS private: - // private instance to be created by H5Library only - static H5Library* instance; - // Default constructor - no instance ever created from outsiders H5Library(); |