summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-18 21:05:05 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-18 21:05:05 (GMT)
commit60957dc6cfa069aa2809732479e004b7813a2054 (patch)
treeb1722219ea39855aefc5d444fd0f31785dc717c8 /c++
parentd6dc8a4dfd95ea0e6b3b6d9cfbb8ea5aad4c19d3 (diff)
downloadhdf5-60957dc6cfa069aa2809732479e004b7813a2054.zip
hdf5-60957dc6cfa069aa2809732479e004b7813a2054.tar.gz
hdf5-60957dc6cfa069aa2809732479e004b7813a2054.tar.bz2
[svn-r15387] Purpose: Fix bug
Description: Enclosed some code that test reference counts in brackets so that temporary objects will go out of scope before checking references. This is to work around the issue where some C++ compilers destroy temporary objects at different time than others. Platforms tested: SunOS 5.10 (linew) Linux 2.6 (kagiso) FreeBSD (duty)
Diffstat (limited to 'c++')
-rw-r--r--c++/test/tattr.cpp29
-rw-r--r--c++/test/tvlstr.cpp2
2 files changed, 16 insertions, 15 deletions
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp
index 6efbda0..fe95fe7 100644
--- a/c++/test/tattr.cpp
+++ b/c++/test/tattr.cpp
@@ -379,7 +379,7 @@ static void test_attr_compound_write()
try {
// Create file
- H5File fid1(FILENAME, H5F_ACC_TRUNC);
+ H5File fid1(FILENAME.c_str(), H5F_ACC_TRUNC);
// Create dataspace for dataset
hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
@@ -1050,6 +1050,11 @@ static void test_attr_dtype_shared()
// Open the file again
fid1.openFile(FILENAME, H5F_ACC_RDWR);
+ // Enclosing to work around the issue of unused variables and/or
+ // objects created by copy constructors stay around until end of
+ // scope, causing incorrect number of ref counts.
+ { // First enclosed block
+
// Create a datatype to commit and use
IntType dtype(PredType::NATIVE_INT);
@@ -1065,13 +1070,6 @@ static void test_attr_dtype_shared()
// Create dataspace for dataset
DataSpace dspace;
- // Enclose the following so that all temporary objects can be
- // destroyed before testing reference count - this is to overcome
- // the different time when the temporary objects are to be destroyed
- // by different compilers.
- {
-
- // Create dataset
DataSet dset = fid1.createDataSet(DSET1_NAME, dtype, dspace);
#ifndef H5_NO_DEPRECATED_SYMBOLS
@@ -1089,8 +1087,8 @@ static void test_attr_dtype_shared()
verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
- // Close attribute
- attr.close();
+ // Close attribute
+ attr.close();
// Delete attribute
dset.removeAttr(ATTR1_NAME);
@@ -1101,8 +1099,8 @@ static void test_attr_dtype_shared()
verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__, __FILE__);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
- // Create attribute on dataset
- attr = dset.createAttribute(ATTR1_NAME,dtype,dspace);
+ // Create attribute on dataset
+ attr = dset.createAttribute(ATTR1_NAME,dtype,dspace);
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
@@ -1118,11 +1116,15 @@ static void test_attr_dtype_shared()
dset.close();
dspace.close();
dtype.close();
+ } // end of first enclosing
+
fid1.close();
// Open the file again
fid1.openFile(FILENAME, H5F_ACC_RDWR);
+ { // Second enclosed block...
+
// Open dataset
DataSet *dset2 = new DataSet (fid1.openDataSet(DSET1_NAME));
@@ -1142,12 +1144,11 @@ static void test_attr_dtype_shared()
fid1.getObjinfo(TYPE1_NAME, statbuf);
verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
+ } // end of second enclosing
// Unlink the dataset
fid1.unlink(DSET1_NAME);
- } // end of enclosing to test reference counts
-
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
fid1.getObjinfo(TYPE1_NAME, statbuf);
diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp
index 469e861..0a11057 100644
--- a/c++/test/tvlstr.cpp
+++ b/c++/test/tvlstr.cpp
@@ -416,7 +416,7 @@ static void test_vlstring_type()
file1 = new H5File(FILENAME, H5F_ACC_RDWR);
// Open the variable-length string datatype just created
- vlstr_type.setId((file1->openStrType(VLSTR_TYPE)).getId());
+ vlstr_type = file1->openStrType(VLSTR_TYPE);
// Verify character set and padding
cset = vlstr_type.getCset();