From 7b5feb741983de363a579ead69f0bafb41654ba0 Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 27 Nov 2006 16:54:24 +0000 Subject: fixed a bug when recombining/merging compressed datasets. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@229 4825ed28-b72c-4eae-9704-e50c059e567d --- src/util/hdf5_merge.c | 8 +++++++- 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); -- cgit v1.2.3