[svn-r15386] Purpose: Fix bug

Description:
    A bug in reference counter was exposed when Ray fixed H5Awrite in
    the main library.  ::setId() called incRefCount when it shouldn't.
    Made sure that id's reference counter is manually incremented
    properly in copy constructor and operator= only.  The main library
    handles the rest.

Platforms tested:
    SunOS 5.10 (linew)
    Linux 2.6 (kagiso)
    FreeBSD (duty)
This commit is contained in:
Binh-Minh Ribler
2008-07-18 15:49:32 -05:00
parent 99e21e85c9
commit d6dc8a4dfd
9 changed files with 91 additions and 188 deletions

View File

@@ -177,58 +177,12 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs )
// copy the data members from the rhs object
setId(rhs.getId());
/* id = rhs.id;
*/
incRefCount(getId()); // a = b, so there are two objects with the same
// hdf5 id
}
return *this;
}
//--------------------------------------------------------------------------
// Function: IdComponent::setId
///\brief Sets the identifier of this object to a new value.
///
///\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
//--------------------------------------------------------------------------
#if 0
void IdComponent::setId(const hid_t new_id)
{
// handling references to this old id
try {
close();
}
catch (Exception close_error) {
throw IdComponentException(inMemFunc("copy"), close_error.getDetailMsg());
}
// reset object's id to the given id
/* id = new_id;
*/
setId(new_id);
// increment the reference counter of the new id
incRefCount();
}
#endif
//--------------------------------------------------------------------------
// Function: IdComponent::getId
///\brief Returns the id of this object
///\return HDF5 id
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
/*
hid_t IdComponent::getId () const
{
return(id);
}
*/
//--------------------------------------------------------------------------
// Function: IdComponent destructor
///\brief Noop destructor.
@@ -273,10 +227,7 @@ H5std_string IdComponent::inMemFunc(const char* func_name) const
///\brief Default constructor.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
IdComponent::IdComponent() {
/* setId(-1);
*/
}
IdComponent::IdComponent() {}
//--------------------------------------------------------------------------
// Function: IdComponent::p_get_file_name (protected)
@@ -335,31 +286,6 @@ hid_t IdComponent::p_dereference(void* ref)
return(temp_id);
}
//--------------------------------------------------------------------------
// Function: IdComponent::p_reference (protected)
// Purpose Creates a reference to an HDF5 object or a dataset region.
// Parameters
// name - IN: Name of the object to be referenced
// dataspace - IN: Dataspace with selection
// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
// Return A reference
// Exception H5::IdComponentException
// Notes This function is incorrect, and will be removed in the near
// future after notifying users of the new APIs ::reference's.
// BMR - Oct 8, 2006
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
/* void* IdComponent::p_reference(const char* name, hid_t space_id, H5R_type_t ref_type) const
{
hobj_ref_t ref;
herr_t ret_value = H5Rcreate(&ref, getId(), name, ref_type, space_id);
if (ret_value < 0)
{
throw IdComponentException("", "H5Rcreate failed");
}
return (reinterpret_cast<void*>(ref));
}
*/
//
// Local functions used in this class
//