diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2008-06-30 19:02:44 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2008-06-30 19:02:44 (GMT) |
commit | 0df059935ca3486b1ece9b88d6de6b0ec656c269 (patch) | |
tree | a16e249660a6c75146dc993116abf1dd8b464da4 /src | |
parent | 49e63a3bebab7541ff855b0a0fbdec406ee55b79 (diff) | |
download | hdf5-0df059935ca3486b1ece9b88d6de6b0ec656c269.zip hdf5-0df059935ca3486b1ece9b88d6de6b0ec656c269.tar.gz hdf5-0df059935ca3486b1ece9b88d6de6b0ec656c269.tar.bz2 |
[svn-r15299] A modification of the changes made in last commit. The problem was that H5Tpack didn't act
correctly with nested compound datatype. This code is better.
Tested on smirom - simple change.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Tcompound.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c index 3c9831b..3f0046a 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, size_t *new_size); +static herr_t H5T_pack(const H5T_t *dt); /*-------------------------------------------------------------------------- @@ -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, NULL) < 0) + if (H5T_pack(dt) < 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, size_t *new_size) +H5T_pack(const H5T_t *dt) { unsigned i; size_t offset; @@ -544,7 +544,7 @@ H5T_pack(const H5T_t *dt, size_t *new_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is read-only") if(dt->shared->parent) { - if (H5T_pack(dt->shared->parent, NULL) < 0) + if (H5T_pack(dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack parent of datatype") /* Adjust size of datatype appropriately */ @@ -555,10 +555,14 @@ H5T_pack(const H5T_t *dt, size_t *new_size) } /* end if */ 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, &(dt->shared->u.compnd.memb[i].size)) < 0) + for (i=0; i<dt->shared->u.compnd.nmembs; i++) { + if (H5T_pack(dt->shared->u.compnd.memb[i].type) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack part of a compound datatype") + /* Update the member size */ + dt->shared->u.compnd.memb[i].size = dt->shared->u.compnd.memb[i].type->shared->size; + } + /* Remove padding between members */ if(H5T_sort_value(dt, NULL)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") @@ -570,10 +574,6 @@ H5T_pack(const H5T_t *dt, size_t *new_size) /* 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 */ |