From 7df8cd5cfe22372f603ea058334647fe4017008e Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Tue, 5 Dec 2000 23:59:37 -0500 Subject: [svn-r3079] Purpose: bug fix - by C API Description: The prototype of two C API functions, H5Tget_offset and H5Sget_simple_extent_npoints was changed to fix bug #446, resulting in the need for updating the two corresponding C++ API functions. Solution: - Changed the return type of AtomType::getOffset from size_t to int, and the error return value from 0 to -1. - Changed the return type of DataSpace::getSimpleExtentNpoints from hsize_t to hssize_t, and the error value from 0 to -1. Platforms tested: arabica (sparc-sun-solaris 2.7) --- c++/src/H5AtomType.C | 11 +++++++---- c++/src/H5AtomType.h | 3 ++- c++/src/H5DataSpace.C | 10 ++++++---- c++/src/H5DataSpace.h | 3 ++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/c++/src/H5AtomType.C b/c++/src/H5AtomType.C index bab1ed3..bdd98b0 100644 --- a/c++/src/H5AtomType.C +++ b/c++/src/H5AtomType.C @@ -89,12 +89,15 @@ void AtomType::setPrecision( size_t precision ) const } // Retrieves the bit offset of the first significant bit. -size_t AtomType::getOffset() const +// 12/05/00: due to C API change +// - return type changed from size_t to int +// - offset = -1 when failure occurs vs. 0 +int AtomType::getOffset() const { - size_t offset = H5Tget_offset( id ); // C routine + int offset = H5Tget_offset( id ); // C routine - // returns a positive offset value if successful - if( offset == 0 ) + // returns a non-negative offset value if successful + if( offset == -1 ) { throw DataTypeIException(); } diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index 165cbf5..14834c3 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -25,7 +25,8 @@ class AtomType : public DataType { void setPrecision( size_t precision ) const; // Retrieves the bit offset of the first significant bit. - size_t getOffset() const; + // 12/05/00 - changed return type to int from size_t - C API + int getOffset() const; // Sets the bit offset of the first significant bit. void setOffset( size_t offset ) const; diff --git a/c++/src/H5DataSpace.C b/c++/src/H5DataSpace.C index 67857ee..746dc39 100644 --- a/c++/src/H5DataSpace.C +++ b/c++/src/H5DataSpace.C @@ -114,12 +114,14 @@ int DataSpace::getSimpleExtentNdims () const } // Determines the number of elements in a dataspace -hsize_t DataSpace::getSimpleExtentNpoints () const +// 12/05/00: due to C API change +// return type hssize_t vs. hsize_t +// num_elements = -1 when failure occurs vs. 0 +hssize_t DataSpace::getSimpleExtentNpoints () const { - hsize_t num_elements = H5Sget_simple_extent_npoints( id ); + hssize_t num_elements = H5Sget_simple_extent_npoints( id ); - // num_elements = 0 when failure occurs - if( num_elements > 0 ) + if( num_elements > -1 ) return( num_elements ); else { diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index ddbb29c..7f0ca83 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -47,7 +47,8 @@ class DataSpace : public IdComponent { int getSimpleExtentNdims () const; // Gets the number of elements in this dataspace. - hsize_t getSimpleExtentNpoints () const; + // 12/05/00 - changed return type to hssize_t from hsize_t - C API + hssize_t getSimpleExtentNpoints () const; // Gets the current class of this dataspace. H5S_class_t getSimpleExtentType () const; -- cgit v0.12