summaryrefslogtreecommitdiffstats
path: root/src/H5Tcompound.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2008-06-27 18:46:32 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2008-06-27 18:46:32 (GMT)
commit8776008f6648362656cf5a9208e67382137cc40b (patch)
treebd7ab157d083ec9e6cb4f6b58fa3f4125da35165 /src/H5Tcompound.c
parentef6ebe54bbd60a7d4e259bff92decd2ead0510de (diff)
downloadhdf5-8776008f6648362656cf5a9208e67382137cc40b.zip
hdf5-8776008f6648362656cf5a9208e67382137cc40b.tar.gz
hdf5-8776008f6648362656cf5a9208e67382137cc40b.tar.bz2
[svn-r15290] H5Tpack didn't act correctly with nested compound datatype. The new size of the type in the
inner nest wasn't passed to the outer nest. This has been fixed. Tested on kagiso, linew, smirom.
Diffstat (limited to 'src/H5Tcompound.c')
-rw-r--r--src/H5Tcompound.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c
index 9942ea1..3c9831b 100644
--- a/src/H5Tcompound.c
+++ b/src/H5Tcompound.c
@@ -31,7 +31,7 @@
#include "H5Tpkg.h" /*data-type functions */
/* Static local functions */
-static herr_t H5T_pack(const H5T_t *dt);
+static herr_t H5T_pack(const H5T_t *dt, size_t *new_size);
/*--------------------------------------------------------------------------
@@ -386,7 +386,7 @@ H5Tpack(hid_t type_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype")
/* Pack */
- if (H5T_pack(dt) < 0)
+ if (H5T_pack(dt, NULL) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound datatype")
done:
@@ -524,7 +524,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5T_pack(const H5T_t *dt)
+H5T_pack(const H5T_t *dt, size_t *new_size)
{
unsigned i;
size_t offset;
@@ -544,7 +544,7 @@ H5T_pack(const H5T_t *dt)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is read-only")
if(dt->shared->parent) {
- if (H5T_pack(dt->shared->parent) < 0)
+ if (H5T_pack(dt->shared->parent, NULL) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack parent of datatype")
/* Adjust size of datatype appropriately */
@@ -556,7 +556,7 @@ H5T_pack(const H5T_t *dt)
else if(dt->shared->type==H5T_COMPOUND) {
/* Recursively pack the members */
for (i=0; i<dt->shared->u.compnd.nmembs; i++)
- if (H5T_pack(dt->shared->u.compnd.memb[i].type) < 0)
+ if (H5T_pack(dt->shared->u.compnd.memb[i].type, &(dt->shared->u.compnd.memb[i].size)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack part of a compound datatype")
/* Remove padding between members */
@@ -570,6 +570,10 @@ H5T_pack(const H5T_t *dt)
/* Change total size */
dt->shared->size = MAX(1, offset);
+ /* Update the member size of compound type in higher level */
+ if(new_size)
+ *new_size = MAX(1, offset);
+
/* Mark the type as packed now */
dt->shared->u.compnd.packed=TRUE;
} /* end if */