diff options
Diffstat (limited to 'src/H5Tcompound.c')
-rw-r--r-- | src/H5Tcompound.c | 14 |
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 */ |