summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2003-09-10 22:59:00 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2003-09-10 22:59:00 (GMT)
commit81c68519658c984e4a0e225c5d54d8e4604f1729 (patch)
tree476754c48fbf41d92a791636216415ee8d624b41 /src
parent1f5e8c2e63a4f3cf34d8f187adc24133caa2d25d (diff)
downloadhdf5-81c68519658c984e4a0e225c5d54d8e4604f1729.zip
hdf5-81c68519658c984e4a0e225c5d54d8e4604f1729.tar.gz
hdf5-81c68519658c984e4a0e225c5d54d8e4604f1729.tar.bz2
[svn-r7461] Purpose: bug #1017
Description: H5Tpack fails if called twice or datatype is locked. Compound datatype wasn't expandable. Platforms tested: h5committest
Diffstat (limited to 'src')
-rw-r--r--src/H5T.c10
-rw-r--r--src/H5Tcompound.c12
-rw-r--r--src/H5Tpkg.h1
3 files changed, 16 insertions, 7 deletions
diff --git a/src/H5T.c b/src/H5T.c
index 8e169f4..0c7257c 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -2633,7 +2633,7 @@ H5Tset_size(hid_t type_id, size_t size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive");
if (size == H5T_VARIABLE && dt->type!=H5T_STRING)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "only strings may be variable length");
- if ((H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) || (H5T_COMPOUND==dt->type && dt->u.compnd.nmembs>0))
+ if ((H5T_ENUM==dt->type && dt->u.enumer.nmembs>0))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined");
if (H5T_REFERENCE==dt->type)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for this datatype");
@@ -3328,7 +3328,7 @@ H5T_create(H5T_class_t type, size_t size)
dt->type = type;
if (NULL==(dt->parent=H5T_copy(H5I_object(subtype), H5T_COPY_ALL)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy base data type");
- break;
+ break;
case H5T_VLEN: /* Variable length datatype */
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tvlen_create()");
@@ -3953,10 +3953,12 @@ H5T_set_size(H5T_t *dt, size_t size)
case H5T_TIME:
case H5T_BITFIELD:
case H5T_OPAQUE:
- case H5T_COMPOUND:
/* nothing to check */
break;
-
+ case H5T_COMPOUND:
+ if(size>dt->size)
+ dt->size = size;
+ break;
case H5T_STRING:
/* Convert string to variable-length datatype */
if(size==H5T_VARIABLE) {
diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c
index 790de46..a571d97 100644
--- a/src/H5Tcompound.c
+++ b/src/H5Tcompound.c
@@ -325,7 +325,9 @@ H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id)
/* Insert */
if (H5T_insert(parent, name, offset, member) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "unable to insert member");
-
+
+ parent->packed = FALSE;
+
done:
FUNC_LEAVE_API(ret_value);
}
@@ -358,12 +360,18 @@ H5Tpack(hid_t type_id)
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
+ /* If datatype has been packed, skip this step and go to done */
+ if(dt->packed == TRUE)
+ HGOTO_DONE(ret_value);
if (H5T_STATE_TRANSIENT!=dt->state)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data type is read-only");
/* Pack */
if (H5T_pack(dt) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound data type");
+
+ /* Indicate datatype has been packed */
+ dt->packed = TRUE;
done:
FUNC_LEAVE_API(ret_value);
@@ -484,8 +492,6 @@ H5T_pack(H5T_t *dt)
assert(dt);
if (H5T_COMPOUND == dt->type) {
- assert(H5T_STATE_TRANSIENT==dt->state);
-
/* Recursively pack the members */
for (i=0; i<dt->u.compnd.nmembs; i++) {
if (H5T_pack(dt->u.compnd.memb[i].type) < 0)
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index 49a1ca8..e6127af 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -194,6 +194,7 @@ struct H5T_t {
H5T_class_t type; /*which class of type is this? */
size_t size; /*total size of an instance of this type */
hbool_t force_conv;/* Set if this type always needs to be converted and H5T_conv_noop cannot be called */
+ hbool_t packed; /*whether a compound type is packed */
struct H5T_t *parent;/*parent type for derived datatypes */
union {
H5T_atomic_t atomic; /* an atomic datatype */