diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2015-10-13 15:15:01 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2015-10-13 15:15:01 (GMT) |
commit | faf35f2d4c9a74eed3e9b34f5b9b334870ee8783 (patch) | |
tree | c5dea3acd87cffea2c3122a8ec789a90f46081b0 /c++/src/H5DataSet.cpp | |
parent | ab8d3b1db99c7579ba21a9bdb3b7c9a4d0461fa9 (diff) | |
download | hdf5-faf35f2d4c9a74eed3e9b34f5b9b334870ee8783.zip hdf5-faf35f2d4c9a74eed3e9b34f5b9b334870ee8783.tar.gz hdf5-faf35f2d4c9a74eed3e9b34f5b9b334870ee8783.tar.bz2 |
[svn-r28052] Purpose: Fix memory leaks
Description:
- Implemented the friend function
void f_PropList_setId(PropList* plist, hid_t new_id)
to work around the same problem described in trunk r26655, for the
API DataSet::getCreatePlist()
- Cleaned up some comments and obsolete functions
Merged from trunk r28047
Platforms tested:
Linux/32 2.6 (jam)
Darwin (osx1010test)
Diffstat (limited to 'c++/src/H5DataSet.cpp')
-rw-r--r-- | c++/src/H5DataSet.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index 9497a08..af1277a 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -60,6 +60,12 @@ DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) {} ///\brief Creates an DataSet object using the id of an existing dataset. ///\param existing_id - IN: Id of an existing dataset // Programmer Binh-Minh Ribler - 2000 +// Description +// incRefCount() is needed here to prevent the id from being closed +// prematurely. That is, when application uses the id of an +// existing DataSet object to create another DataSet object. So, +// when one of those objects is deleted, the id will be closed if +// the reference counter is only 1. //-------------------------------------------------------------------------- DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs() { @@ -170,8 +176,10 @@ DSetCreatPropList DataSet::getCreatePlist() const { throw DataSetIException("DataSet::getCreatePlist", "H5Dget_create_plist failed"); } + // create and return the DSetCreatPropList object - DSetCreatPropList create_plist(create_plist_id); // ok to use existing id const + DSetCreatPropList create_plist; + f_PropList_setId(&create_plist, create_plist_id); return(create_plist); } @@ -770,6 +778,22 @@ void DataSet::p_setId(const hid_t new_id) // reset object's id to the given id id = new_id; } + +//-------------------------------------------------------------------------- +// Function: f_PropList_setId - friend +// Purpose: This function is friend to class H5::PropList so that it +// can set PropList::id in order to work around a problem +// described in the JIRA issue HDFFV-7947. +// Applications shouldn't need to use it. +// param dset - IN/OUT: DataSet object to be changed +// param new_id - IN: New id to set +// Programmer Binh-Minh Ribler - 2015 +//-------------------------------------------------------------------------- +void f_PropList_setId(PropList* plist, hid_t new_id) +{ + plist->p_setId(new_id); +} + #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- |