summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-01-19 02:51:12 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-01-19 02:51:12 (GMT)
commitfabb06712b15f111c7ccce8c394ff6fc9bd2f997 (patch)
tree51b5f57598d1ff355090e481a8268ee5ba80e88c /c++
parentb8f7cdc48d9c8470fdf8930938e75b50210150fb (diff)
downloadhdf5-fabb06712b15f111c7ccce8c394ff6fc9bd2f997.zip
hdf5-fabb06712b15f111c7ccce8c394ff6fc9bd2f997.tar.gz
hdf5-fabb06712b15f111c7ccce8c394ff6fc9bd2f997.tar.bz2
[svn-r9838] Purpose:
Bug fix Description: Correctly retire the H5E_LEN setting, now that the FORTRAN and C++ APIs have been corrected to not use it either. Solution: Pass in the string buffer length for FORTRAN In the C++ API, call H5Eget_msg() in a manner similar to the way H5Fget_name() is called. Platforms tested: Linux 2.4 (heping) w/FORTRAN & C++ Solaris 2.7 (arabica) w/FORTRAN & C++
Diffstat (limited to 'c++')
-rw-r--r--c++/src/H5Exception.cpp48
1 files changed, 40 insertions, 8 deletions
diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp
index d89f486..aef0d9c 100644
--- a/c++/src/H5Exception.cpp
+++ b/c++/src/H5Exception.cpp
@@ -66,10 +66,26 @@ Exception::Exception( const Exception& orig )
//--------------------------------------------------------------------------
string Exception::getMajorString( hid_t err_major ) const
{
- // calls the C API routine to get the major string
- char msg[H5E_LEN];
- H5Eget_msg(err_major, NULL, msg, H5E_LEN);
- string major_str(msg);
+ // Preliminary call to H5Eget_msg() to get the length of the message
+ ssize_t mesg_size = H5Eget_msg(err_major, NULL, NULL, 0);
+
+ // If H5Eget_msg() returns a negative value, raise an exception,
+ if( mesg_size < 0 )
+ throw IdComponentException("Exception::getMajorString",
+ "H5Eget_msg failed");
+
+ // Call H5Eget_msg again to get the actual message
+ char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API
+ mesg_size = H5Eget_msg(err_major, NULL, mesg_C, mesg_size+1);
+
+ // Check for failure again
+ if( mesg_size < 0 )
+ throw IdComponentException("Exception::getMajorString",
+ "H5Eget_msg failed");
+
+ // Convert the C error description and return
+ string major_str(mesg_C);
+ delete mesg_C;
return( major_str );
}
@@ -86,10 +102,26 @@ string Exception::getMajorString( hid_t err_major ) const
//--------------------------------------------------------------------------
string Exception::getMinorString( hid_t err_minor ) const
{
- // calls the C API routine to get the minor string
- char msg[H5E_LEN];
- H5Eget_msg(err_minor, NULL, msg, H5E_LEN);
- string minor_str(msg);
+ // Preliminary call to H5Eget_msg() to get the length of the message
+ ssize_t mesg_size = H5Eget_msg(err_minor, NULL, NULL, 0);
+
+ // If H5Eget_msg() returns a negative value, raise an exception,
+ if( mesg_size < 0 )
+ throw IdComponentException("Exception::getMinorString",
+ "H5Eget_msg failed");
+
+ // Call H5Eget_msg again to get the actual message
+ char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API
+ mesg_size = H5Eget_msg(err_minor, NULL, mesg_C, mesg_size+1);
+
+ // Check for failure again
+ if( mesg_size < 0 )
+ throw IdComponentException("Exception::getMinorString",
+ "H5Eget_msg failed");
+
+ // Convert the C error description and return
+ string minor_str(mesg_C);
+ delete mesg_C;
return( minor_str );
}