summaryrefslogtreecommitdiffstats
path: root/c++/src/H5DataSet.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2015-04-06 03:52:35 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2015-04-06 03:52:35 (GMT)
commit2a2a79742dc2ee154b7571a518b97413599b29a6 (patch)
treecda2e53402608cdf22eb2be41d27c6bb63c32ad9 /c++/src/H5DataSet.cpp
parent150b85cc44903c005009552d692da50a4aa6c86f (diff)
downloadhdf5-2a2a79742dc2ee154b7571a518b97413599b29a6.zip
hdf5-2a2a79742dc2ee154b7571a518b97413599b29a6.tar.gz
hdf5-2a2a79742dc2ee154b7571a518b97413599b29a6.tar.bz2
[svn-r26731] Purpose: Fixed HDFFV-7947
Description: When copy constructor or constructor that takes an existing id is invoked, the C ref counter stays the same but there is an extra C++ object which later is destroyed and may cause the HDF5 id to be closed prematurely. The C++ library needs to increment the ref counter in these situations, so that the C library will not close the id when it is still being referenced. However, the incrementing of ref count left some objects opened at the end of the program, perhaps, due to compiler's optimization on cons/destructors. The constructor, that takes an existing id, needs to increment the counter but it seems that the matching destructor wasn't invoked. The workaround is to have a function for each class that has "id" that only sets the id and not increment the ref count for the library to use in these situations. These functions are "friend" and not public. The friend functions are: void f_Attribute_setId(Attribute *, hid_t) void f_DataSet_setId(DataSet *, hid_t) void f_DataSpace_setId(DataSpace *, hid_t) void f_DataType_setId(DataType *, hid_t) Merged from trunk: r26655 Platforms tested: Linux/64 (platypus) Linux/32 2.6 (jam Intel 15.0) SunOS 5.11 (emu)
Diffstat (limited to 'c++/src/H5DataSet.cpp')
-rw-r--r--c++/src/H5DataSet.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index b0f49bf..8917f91 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -135,7 +135,8 @@ DataSpace DataSet::getSpace() const
throw DataSetIException("DataSet::getSpace", "H5Dget_space failed");
}
//create dataspace object using the existing id then return the object
- DataSpace data_space( dataspace_id );
+ DataSpace data_space;
+ f_DataSpace_setId(&data_space, dataspace_id);
return( data_space );
}
@@ -168,8 +169,8 @@ DSetCreatPropList DataSet::getCreatePlist() const
throw DataSetIException("DataSet::getCreatePlist", "H5Dget_create_plist failed");
}
// create and return the DSetCreatPropList object
- DSetCreatPropList create_plist( create_plist_id );
- return( create_plist );
+ DSetCreatPropList create_plist(create_plist_id); // ok to use existing id const
+ return(create_plist);
}
//--------------------------------------------------------------------------