summaryrefslogtreecommitdiffstats
path: root/src/H5T.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-09-12 04:36:23 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-09-12 04:36:23 (GMT)
commitf3e445cfcb4573ce87212cf7046a3f67f36d616f (patch)
tree3e75cee494b31453d15f66c02d10922b4c10eea1 /src/H5T.c
parent75471825fde4e55fb23cda381563372bc91795e1 (diff)
downloadhdf5-f3e445cfcb4573ce87212cf7046a3f67f36d616f.zip
hdf5-f3e445cfcb4573ce87212cf7046a3f67f36d616f.tar.gz
hdf5-f3e445cfcb4573ce87212cf7046a3f67f36d616f.tar.bz2
[svn-r7469] Purpose:
Code cleanup, etc. Description: Generalize Ray's datatype fixes to handle packing compound datatypes which are the base type of an array or variable-length type, etc. Also track "packedness" of a compound datatype from it's creation, instead of only setting the 'packed' flag after the datatype was explicitly packed. Updated docs to reflect that a compound datatype is allowed to grow (but not shrink). Platforms tested: FreeBSD 4.9 (sleipnir) h5committest
Diffstat (limited to 'src/H5T.c')
-rw-r--r--src/H5T.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/H5T.c b/src/H5T.c
index 13f57a2..f27a8f0 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -2660,7 +2660,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");
@@ -3334,6 +3334,8 @@ H5T_create(H5T_class_t type, size_t size)
if (NULL==(dt = H5FL_CALLOC(H5T_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
dt->type = type;
+ if(type==H5T_COMPOUND)
+ dt->u.compnd.packed=TRUE; /* Start out packed */
break;
case H5T_ENUM:
@@ -4014,10 +4016,14 @@ 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)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "can't shrink compound datatype");
+ break;
+
case H5T_STRING:
/* Convert string to variable-length datatype */
if(size==H5T_VARIABLE) {