diff options
Diffstat (limited to 'c++/src/H5DataType.cpp')
-rw-r--r-- | c++/src/H5DataType.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index aed0dd1..714f55f 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -123,7 +123,7 @@ DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type) // Jul, 2008 // Added for application convenience. //-------------------------------------------------------------------------- -DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object(), id(H5I_INVALID_HID) +DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object() { id = H5Location::p_dereference(attr.getId(), ref, ref_type, "constructor - by dereference"); } @@ -141,18 +141,23 @@ DataType::DataType(const DataType& original) : H5Object() //-------------------------------------------------------------------------- // Function: DataType overloaded constructor -///\brief Creates a integer type using a predefined type -///\param pred_type - IN: Predefined datatype +///\brief Creates a DataType instance using a predefined type +///\param pred_type - IN: Predefined type instance ///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2015 // Description -// This is so that when a predefined type is passed in, a -// copy of it is made, not just a duplicate of the HDF5 id. +// Copying the type so that when a predefined type is passed in, +// a copy of it is made, not just a duplicate of the HDF5 id. +// Note: calling DataType::copy will invoke DataType::close() +// unnecessarily and will produce undefined behavior. +// -BMR, Apr 2015 //-------------------------------------------------------------------------- DataType::DataType(const PredType& pred_type) : H5Object() { - // use DataType::copy to make a copy of this predefined type - copy(pred_type); + // call C routine to copy the datatype + id = H5Tcopy( pred_type.getId() ); + if( id < 0 ) + throw DataTypeIException("DataType constructor", "H5Tcopy failed"); } //-------------------------------------------------------------------------- |