diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2006-12-11 03:22:24 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2006-12-11 03:22:24 (GMT) |
commit | 107260878ca512e7b14ee60e5e675963a7e35c96 (patch) | |
tree | 7a3ed8801ca222bfe086a6af78f805356236493d | |
parent | 2db5379dbbcd07dd8d15735d4953b1655664c55a (diff) | |
download | hdf5-107260878ca512e7b14ee60e5e675963a7e35c96.zip hdf5-107260878ca512e7b14ee60e5e675963a7e35c96.tar.gz hdf5-107260878ca512e7b14ee60e5e675963a7e35c96.tar.bz2 |
[svn-r13040] Purpose: Fixed user reported bug
Description:
In Attribute::read, H5Aread malloc's memory for the read data buffer,
so Attribute::read shouldn't allocate the buffer, but needs to
deallocate with HDfree.
Fixed a typo in H5StrType.cpp, should pass PredType::C_S1 to "copy"
instead of H5T_C_S1.
Also changed DataSet::vlenReclaim to static.
Platforms tested:
AIX 5.1 (copper)
Linux 2.6 (kagiso)
SunOS 5.8 64-bit (sol)
-rw-r--r-- | c++/src/H5Attribute.cpp | 13 | ||||
-rw-r--r-- | c++/src/H5DataSet.h | 2 | ||||
-rw-r--r-- | c++/src/H5StrType.cpp | 2 |
3 files changed, 10 insertions, 7 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 9c3d63f..b155a12 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -30,6 +30,7 @@ #include "H5CommonFG.h" #include "H5DataType.h" #include "H5DataSpace.h" +#include "H5private.h" #ifndef H5_NO_NAMESPACE namespace H5 { @@ -131,15 +132,17 @@ void Attribute::read( const DataType& mem_type, void *buf ) const //-------------------------------------------------------------------------- void Attribute::read( const DataType& mem_type, H5std_string& strg ) const { - size_t size = mem_type.getSize(); - char* strg_C = new char[size+1]; // temporary C-string for C API - herr_t ret_value = H5Aread( id, mem_type.getId(), &strg_C ); + char* strg_C; // temporary C-string for C API + + // call C API to get the attribute string of chars + herr_t ret_value = H5Aread( id, mem_type.getId(), &strg_C); + if( ret_value < 0 ) { throw AttributeIException("Attribute::read", "H5Aread failed"); } - strg = strg_C; - delete []strg_C; + strg = strg_C; // get 'string' from the C char* + HDfree(strg_C); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index a186607..c698906 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -52,7 +52,7 @@ class H5_DLLCPP DataSet : public AbstractDs { // not yet implemented?? hsize_t getVlenBufSize( DataType& type, DataSpace& space ) const; - void vlenReclaim( DataType& type, DataSpace& space, DSetMemXferPropList& xfer_plist, void* buf ) const; + static void vlenReclaim( DataType& type, DataSpace& space, DSetMemXferPropList& xfer_plist, void* buf ); // Reads the data of this dataset and stores it in the provided buffer. // The memory and file dataspaces and the transferring property list diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index 849f345..bbf2bf5 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -102,7 +102,7 @@ StrType::StrType( const int dummy, const size_t& size ) : AtomType() { // use DataType::copy to make a copy of the string predefined type // then set its length - copy(H5T_C_S1); + copy(PredType::C_S1); setSize(size); } |