From 6f2de2c62cdc8a6def14fd06b0b25fae1d487d28 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Sun, 20 Feb 2005 15:45:44 -0500 Subject: [svn-r10050] Purpose: Fix bugzilla #241 Description: Checked return value from C API for failure condition. Added/Modified some comments appropriately. Platforms tested: Linux 2.4 (heping) AIX 5.1 (copper) - tests passed but there were some old warnings about duplicate symbols on std::string; I'll check on that. --- c++/src/H5Attribute.cpp | 3 +++ c++/src/H5DataSet.cpp | 3 +++ c++/src/H5DataSpace.cpp | 6 ++++++ c++/src/H5DataType.cpp | 6 ++++++ c++/src/H5File.cpp | 12 ++++++++++-- c++/src/H5Group.cpp | 3 +++ c++/src/H5PropList.cpp | 11 +++++++---- 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 6c9b1b3..7c70966 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -260,6 +260,9 @@ string Attribute::getName() const // Function: Attribute destructor ///\brief Properly terminates access to this attribute. // Programmer Binh-Minh Ribler - 2000 +// Modification +// Replaced resetIdComponent with decRefCount to use new ID +// reference counting mechanisms by Quincey Koziol, June 1, 2004 //-------------------------------------------------------------------------- Attribute::~Attribute() { diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index 455888c..635c9fa 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -482,6 +482,9 @@ DataSpace DataSet::getRegion(void *ref, H5R_type_t ref_type) const // Function: DataSet destructor ///\brief Properly terminates access to this dataset. // Programmer Binh-Minh Ribler - 2000 +// Modification +// Replaced resetIdComponent with decRefCount to use new ID +// reference counting mechanisms by Quincey Koziol, June 1, 2004 //-------------------------------------------------------------------------- DataSet::~DataSet() { diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index f5584a6..7250285 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -93,6 +93,9 @@ 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 Quincey Koziol, June 1, 2004 //-------------------------------------------------------------------------- void DataSpace::copy( const DataSpace& like_space ) { @@ -538,6 +541,9 @@ void DataSpace::selectHyperslab( H5S_seloper_t op, const hsize_t *count, const h // 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 Quincey Koziol, June 1, 2004 //-------------------------------------------------------------------------- DataSpace::~DataSpace() { diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 4fc7238..68c8b5d 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -94,6 +94,9 @@ DataType::DataType(const DataType& original) : H5Object(original) ///\param like_type - IN: Datatype to be copied ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 +// Modification +// Replaced resetIdComponent with decRefCount to use new ID +// reference counting mechanisms by Quincey Koziol, June 1, 2004 //-------------------------------------------------------------------------- void DataType::copy( const DataType& like_type ) { @@ -598,6 +601,9 @@ DataSpace DataType::getRegion(void *ref, H5R_type_t ref_type) const // Function: DataType destructor ///\brief Properly terminates access to this datatype. // Programmer Binh-Minh Ribler - 2000 +// Modification +// Replaced resetIdComponent with decRefCount to use new ID +// reference counting mechanisms by Quincey Koziol, June 1, 2004 //-------------------------------------------------------------------------- DataType::~DataType() { diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index afc692b..3d650ed 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -181,11 +181,16 @@ bool H5File::isHdf5(const string& name ) // If this object has represented another HDF5 file, the previous // HDF5 file need to be closed first. // Programmer Binh-Minh Ribler - 2000 +// Modification +// Replaced resetIdComponent with decRefCount to use new ID +// reference counting mechanisms by Quincey Koziol, June 1, 2004 +// Note: This wrapper doesn't seem right regarding the 'id' and should +// be investigated. BMR - 2/20/2005 //-------------------------------------------------------------------------- void H5File::reOpen() { - // reset the identifier of this H5File - send 'this' in so that - // H5Fclose can be called appropriately + // If this object has a valid id, appropriately decrement reference + // counter and close the id. try { decRefCount(); } @@ -551,6 +556,9 @@ void H5File::throwException(const string func_name, const string msg) const // Function: H5File destructor ///\brief Properly terminates access to this file. // Programmer Binh-Minh Ribler - 2000 +// Modification +// Replaced resetIdComponent with decRefCount to use new ID +// reference counting mechanisms by Quincey Koziol, June 1, 2004 //-------------------------------------------------------------------------- H5File::~H5File() { diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 5a00922..95bce03 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -166,6 +166,9 @@ void Group::throwException(const string func_name, const string msg) const // Function: Group destructor ///\brief Properly terminates access to this group. // Programmer Binh-Minh Ribler - 2000 +// Modification +// Replaced resetIdComponent with decRefCount to use new ID +// reference counting mechanisms by Quincey Koziol, June 1, 2004 //-------------------------------------------------------------------------- Group::~Group() { diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index a9dd22a..8e2c12b 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -86,11 +86,14 @@ PropList::PropList( const hid_t plist_id ) : IdComponent(0) ///\param like_plist - IN: Reference to the existing property list ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 +// Modification +// Replaced resetIdComponent with decRefCount to use new ID +// reference counting mechanisms by Quincey Koziol, June 1, 2004 //-------------------------------------------------------------------------- void PropList::copy( const PropList& like_plist ) { - // reset the identifier of this PropList - send 'this' in so that - // H5Pclose can be called appropriately + // If this object has a valid id, appropriately decrement reference + // counter and close the id. try { decRefCount(); } @@ -324,7 +327,7 @@ size_t PropList::getPropSize(const char *name) const { size_t prop_size; herr_t ret_value = H5Pget_size(id, name, &prop_size); - if (prop_size < 0) + if (ret_value < 0) { throw PropListIException("PropList::getPropSize", "H5Pget_size failed"); } @@ -376,7 +379,7 @@ size_t PropList::getNumProps() const { size_t nprops; herr_t ret_value = H5Pget_nprops (id, &nprops); - if( nprops < 0 ) + if (ret_value < 0) { throw PropListIException("PropList::getNumProps", "H5Pget_nprops failed"); } -- cgit v0.12