diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2005-02-20 22:07:55 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2005-02-20 22:07:55 (GMT) |
commit | ab0253507459c6b163fad1c5039f54bdb3fa3f5c (patch) | |
tree | f049cd04f8cf6f29e83682939562003f9487abb9 /c++/src/H5DataSpace.cpp | |
parent | b362c692dc09558ce93b1d27aa59d4646201ad32 (diff) | |
download | hdf5-ab0253507459c6b163fad1c5039f54bdb3fa3f5c.zip hdf5-ab0253507459c6b163fad1c5039f54bdb3fa3f5c.tar.gz hdf5-ab0253507459c6b163fad1c5039f54bdb3fa3f5c.tar.bz2 |
[svn-r10051] Purpose: Fix bugzilla #242
Description:
In the release branch, RefCounter was still used for maintaining
the reference count and there was a memory leak problem (bug 242)
which is not a simple fix.
Solution:
Removed this reference counting approach completely and started
using the C library's new APIs for that purpose.
Platforms tested:
Linux 2.4 (heping)
SunOS 5.8 64-bit (sol)
Diffstat (limited to 'c++/src/H5DataSpace.cpp')
-rw-r--r-- | c++/src/H5DataSpace.cpp | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index 1dc7b43..d13deed 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -20,10 +20,8 @@ #endif #include "H5Include.h" -#include "H5RefCounter.h" #include "H5Exception.h" #include "H5IdComponent.h" -#include "H5Idtemplates.h" #include "H5DataSpace.h" #ifndef H5_NO_NAMESPACE @@ -95,23 +93,26 @@ DataSpace::DataSpace( const DataSpace& original ) : IdComponent( original ) {} ///\param like_space - IN: Dataspace to be copied ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 +// Modification +// Replaced resetIdComponent with decRefCount to use new ID +// reference counting mechanisms by QAK, Feb 20, 2005 //-------------------------------------------------------------------------- void DataSpace::copy( const DataSpace& like_space ) { - // reset the identifier of this object - send 'this' in so that - // H5Sclose can be called appropriately - try { - resetIdComponent( this ); } - catch (Exception close_error) { // thrown by p_close - throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); - } + // If this object has a valid id, appropriately decrement reference + // counter and close the id. + if( id != H5S_ALL ) { + try { + decRefCount(); + } + catch (Exception close_error) { + throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); + } + } // if - // call C routine to copy the dataspace + // call C routine to copy the dataspace id = H5Scopy( like_space.getId() ); - // new ref counter for this id - ref_count = new RefCounter; - if( id <= 0 ) throw DataSpaceIException("DataSpace::copy", "H5Scopy failed"); } @@ -564,15 +565,22 @@ void DataSpace::p_close() const // Function: DataSpace destructor ///\brief Properly terminates access to this dataspace. // Programmer Binh-Minh Ribler - 2000 +// Modification +// Replaced resetIdComponent with decRefCount to use new ID +// reference counting mechanisms by QAK, Feb 20, 2005 //-------------------------------------------------------------------------- DataSpace::~DataSpace() { - // The dataspace id will be closed properly - try { - resetIdComponent( this ); } - catch (Exception close_error) { // thrown by p_close - cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl; - } + // If this object has a valid id, appropriately decrement reference + // counter and close the id. + if( id != H5S_ALL ) { + try { + decRefCount(); + } + catch (Exception close_error) { + throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); + } + } // if } #ifndef H5_NO_NAMESPACE |