summaryrefslogtreecommitdiffstats
path: root/src/H5Odtype.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Odtype.c')
-rw-r--r--src/H5Odtype.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 1e70ff9..d6de6f6 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -273,10 +273,6 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
if(temp_type->force_conv==TRUE)
dt->force_conv=TRUE;
- /* Set the "has array" flag if array datatype fields exist in this type */
- if(temp_type->type==H5T_ARRAY)
- dt->u.compnd.has_array=TRUE;
-
/* Member size */
dt->u.compnd.memb[i].size = temp_type->size;
@@ -435,6 +431,7 @@ done:
static herr_t
H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
{
+ htri_t has_array=FALSE; /* Whether a compound datatype has an array inside it */
unsigned flags = 0;
char *hdr = (char *)*pp;
int i, j;
@@ -624,6 +621,10 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
break;
case H5T_COMPOUND:
+ /* Check for an array datatype somewhere within the compound type */
+ if((has_array=H5T_detect_class(dt,H5T_ARRAY))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't detect array class");
+
/*
* Compound data types...
*/
@@ -644,7 +645,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
* member information, for better backward compatibility
* Write out all zeros for the array information, though...
*/
- if(!dt->u.compnd.has_array) {
+ if(!has_array) {
/* Dimensionality */
*(*pp)++ = 0;
@@ -768,7 +769,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
}
/* Encode the type's class, version and bit field */
- *hdr++ = ((unsigned)(dt->type) & 0x0f) | (((dt->type==H5T_COMPOUND && dt->u.compnd.has_array) ? H5O_DTYPE_VERSION_UPDATED : H5O_DTYPE_VERSION_COMPAT )<<4);
+ *hdr++ = ((unsigned)(dt->type) & 0x0f) | (((dt->type==H5T_COMPOUND && has_array) ? H5O_DTYPE_VERSION_UPDATED : H5O_DTYPE_VERSION_COMPAT )<<4);
*hdr++ = (flags >> 0) & 0xff;
*hdr++ = (flags >> 8) & 0xff;
*hdr++ = (flags >> 16) & 0xff;