summaryrefslogtreecommitdiffstats
path: root/c++/src
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2014-10-01 04:31:37 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2014-10-01 04:31:37 (GMT)
commit1df7b415ab51697c3e5af31fcfc799c07c0b82b6 (patch)
treec875e40378353c4e9e6f2669fb4f4d455bb228e6 /c++/src
parent22d0d32716a588063970a7e412d69a2937118034 (diff)
downloadhdf5-1df7b415ab51697c3e5af31fcfc799c07c0b82b6.zip
hdf5-1df7b415ab51697c3e5af31fcfc799c07c0b82b6.tar.gz
hdf5-1df7b415ab51697c3e5af31fcfc799c07c0b82b6.tar.bz2
[svn-r25645] Description:
Removed the try/block with new/bad_alloc that were unintentionally committed previously. Platforms tested: Linux/ppc64 (ostrich) Linux/32 2.6 (jam) SunOS 5.11 (emu)
Diffstat (limited to 'c++/src')
-rw-r--r--c++/src/H5ArrayType.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp
index 5a3f860..8807dca 100644
--- a/c++/src/H5ArrayType.cpp
+++ b/c++/src/H5ArrayType.cpp
@@ -57,12 +57,10 @@ ArrayType::ArrayType( const hid_t existing_id ) : DataType( existing_id )
throw DataTypeIException("ArrayType constructor (existing id)", "H5Tget_array_ndims failed");
}
+ // Allocate space for the dimensions
+ dimensions = new hsize_t[rank];
+
// Get the dimensions of the existing array and store it in this array
- try {
- dimensions = new hsize_t[rank];
- } catch (const std::bad_alloc&) {
- throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed");
- }
int ret_value = H5Tget_array_dims2(id, dimensions);
if (ret_value < 0)
throw DataTypeIException("ArrayType constructor (existing id)", "H5Tget_array_dims2 failed");
@@ -75,12 +73,11 @@ ArrayType::ArrayType( const hid_t existing_id ) : DataType( existing_id )
//--------------------------------------------------------------------------
ArrayType::ArrayType( const ArrayType& original ) : DataType( original )
{
+ // Copy the rank of the original array
rank = original.rank;
- try {
- dimensions = new hsize_t[rank];
- } catch (const std::bad_alloc&) {
- throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed");
- }
+
+ // Allocate space then copy the dimensions from the original array
+ dimensions = new hsize_t[rank];
for (int i = 0; i < rank; i++)
dimensions[i] = original.dimensions[i];
}
@@ -97,16 +94,17 @@ ArrayType::ArrayType( const ArrayType& original ) : DataType( original )
//--------------------------------------------------------------------------
ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) : DataType()
{
+ // Call C API to create an array data type
hid_t new_type_id = H5Tarray_create2(base_type.getId(), ndims, dims);
if (new_type_id < 0)
throw DataTypeIException("ArrayType constructor", "H5Tarray_create2 failed");
+
+ // Set the id and rank for this object
id = new_type_id;
rank = ndims;
- try {
- dimensions = new hsize_t[rank];
- } catch (const std::bad_alloc&) {
- throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed");
- }
+
+ // Allocate space then set the dimensions as provided by caller
+ dimensions = new hsize_t[rank];
for (int i = 0; i < rank; i++)
dimensions[i] = dims[i];
}
@@ -143,23 +141,19 @@ int ArrayType::getArrayNDims()
//--------------------------------------------------------------------------
int ArrayType::getArrayDims(hsize_t* dims)
{
- // if the array's dimensions have not been stored, retrieve them via C API
+ // If the array's dimensions have not been stored, retrieve them via C API
if (dimensions == NULL)
{
int ndims = H5Tget_array_dims2(id, dims);
if (ndims < 0)
throw DataTypeIException("ArrayType::getArrayDims", "H5Tget_array_dims2 failed");
- // store the array's info in memory
+ // Store the array's info in memory
rank = ndims;
- try {
- dimensions = new hsize_t[rank];
- } catch (const std::bad_alloc&) {
- throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed");
- }
+ dimensions = new hsize_t[rank];
for (int i = 0; i < rank; i++)
dimensions[i] = dims[i];
}
- // otherwise, simply copy what's in 'dimensions' to 'dims'
+ // Otherwise, simply copy what's in 'dimensions' to 'dims'
for (int i = 0; i < rank; i++)
dims[i] = dimensions[i];
return(rank);