diff options
-rw-r--r-- | src/util/hdf5_merge.c | 8 | ||||
-rw-r--r-- | src/util/hdf5_recombiner.c | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/util/hdf5_merge.c b/src/util/hdf5_merge.c index 225cb7e..12cd0ec 100644 --- a/src/util/hdf5_merge.c +++ b/src/util/hdf5_merge.c @@ -267,10 +267,16 @@ static herr_t CopyObject (hid_t from, CHECK_ERROR (dataspace = H5Dget_space (from)); CHECK_ERROR (to = H5Dcreate (to, objectname, datatype, dataspace, H5P_DEFAULT)); - objectsize = H5Dget_storage_size (from); + objectsize = H5Sget_select_npoints (dataspace) * H5Tget_size (datatype); if (objectsize > 0) { data = malloc (objectsize); + if (data == NULL) + { + fprintf (stderr, "failled to allocate %d bytes of memory, giving up\n", + objectsize); + exit (-1); + } CHECK_ERROR (H5Dread (from, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data)); CHECK_ERROR (H5Dwrite (to, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT,data)); diff --git a/src/util/hdf5_recombiner.c b/src/util/hdf5_recombiner.c index 8891bbe..c3c662d 100644 --- a/src/util/hdf5_recombiner.c +++ b/src/util/hdf5_recombiner.c @@ -479,7 +479,7 @@ static herr_t CopyObject (hid_t from, CHECK_ERROR (dataspace = H5Dget_space (from)); CHECK_ERROR (to = H5Dcreate (to, objectname, datatype, dataspace, H5P_DEFAULT)); - objectsize = H5Dget_storage_size (from); + objectsize = H5Sget_select_npoints (dataspace) * H5Tget_size (datatype); if (objectsize > 0) { data = malloc (objectsize); |