summaryrefslogtreecommitdiffstats
path: root/src/H5Odtype.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /src/H5Odtype.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'src/H5Odtype.c')
-rw-r--r--src/H5Odtype.c1319
1 files changed, 636 insertions, 683 deletions
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 80dbae9..c8cd954 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -11,108 +11,103 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include "H5Omodule.h" /* This source code file is part of the H5O module */
-#define H5T_FRIEND /*prevent warning from including H5Tpkg */
-
-
-#include "H5private.h" /* Generic Functions */
-#include "H5Dprivate.h" /* Datasets */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* Files */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Gprivate.h" /* Groups */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Opkg.h" /* Object headers */
-#include "H5Tpkg.h" /* Datatypes */
-#include "H5VMprivate.h" /* Vectors and arrays */
-
+#include "H5Omodule.h" /* This source code file is part of the H5O module */
+#define H5T_FRIEND /*prevent warning from including H5Tpkg */
+
+#include "H5private.h" /* Generic Functions */
+#include "H5Dprivate.h" /* Datasets */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* Files */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Gprivate.h" /* Groups */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Opkg.h" /* Object headers */
+#include "H5Tpkg.h" /* Datatypes */
+#include "H5VMprivate.h" /* Vectors and arrays */
/* PRIVATE PROTOTYPES */
static herr_t H5O__dtype_encode(H5F_t *f, uint8_t *p, const void *mesg);
-static void *H5O__dtype_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags,
- unsigned *ioflags, size_t p_size, const uint8_t *p);
-static void *H5O__dtype_copy(const void *_mesg, void *_dest);
+static void * H5O__dtype_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
+ size_t p_size, const uint8_t *p);
+static void * H5O__dtype_copy(const void *_mesg, void *_dest);
static size_t H5O__dtype_size(const H5F_t *f, const void *_mesg);
static herr_t H5O__dtype_reset(void *_mesg);
static herr_t H5O__dtype_free(void *_mesg);
static herr_t H5O__dtype_set_share(void *_mesg, const H5O_shared_t *sh);
static htri_t H5O__dtype_can_share(const void *_mesg);
-static herr_t H5O__dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src,
- hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
-static void *H5O__dtype_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
- void *native_src, H5F_t *file_dst, hbool_t *recompute_size,
- H5O_copy_t *cpy_info, void *udata);
-static herr_t H5O__dtype_shared_post_copy_upd(const H5O_loc_t *src_oloc,
- const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst,
- H5O_copy_t *cpy_info);
-static herr_t H5O__dtype_debug(H5F_t *f, const void *_mesg, FILE * stream,
- int indent, int fwidth);
+static herr_t H5O__dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted,
+ const H5O_copy_t *cpy_info, void *_udata);
+static void * H5O__dtype_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, void *native_src,
+ H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info,
+ void *udata);
+static herr_t H5O__dtype_shared_post_copy_upd(const H5O_loc_t *src_oloc, const void *mesg_src,
+ H5O_loc_t *dst_oloc, void *mesg_dst, H5O_copy_t *cpy_info);
+static herr_t H5O__dtype_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth);
/* Set up & include shared message "interface" info */
-#define H5O_SHARED_TYPE H5O_MSG_DTYPE
-#define H5O_SHARED_DECODE H5O__dtype_shared_decode
-#define H5O_SHARED_DECODE_REAL H5O__dtype_decode
-#define H5O_SHARED_ENCODE H5O__dtype_shared_encode
-#define H5O_SHARED_ENCODE_REAL H5O__dtype_encode
-#define H5O_SHARED_SIZE H5O__dtype_shared_size
-#define H5O_SHARED_SIZE_REAL H5O__dtype_size
-#define H5O_SHARED_DELETE H5O__dtype_shared_delete
+#define H5O_SHARED_TYPE H5O_MSG_DTYPE
+#define H5O_SHARED_DECODE H5O__dtype_shared_decode
+#define H5O_SHARED_DECODE_REAL H5O__dtype_decode
+#define H5O_SHARED_ENCODE H5O__dtype_shared_encode
+#define H5O_SHARED_ENCODE_REAL H5O__dtype_encode
+#define H5O_SHARED_SIZE H5O__dtype_shared_size
+#define H5O_SHARED_SIZE_REAL H5O__dtype_size
+#define H5O_SHARED_DELETE H5O__dtype_shared_delete
#undef H5O_SHARED_DELETE_REAL
-#define H5O_SHARED_LINK H5O__dtype_shared_link
+#define H5O_SHARED_LINK H5O__dtype_shared_link
#undef H5O_SHARED_LINK_REAL
-#define H5O_SHARED_COPY_FILE H5O__dtype_shared_copy_file
-#define H5O_SHARED_COPY_FILE_REAL H5O__dtype_copy_file
-#define H5O_SHARED_POST_COPY_FILE H5O__dtype_shared_post_copy_file
-#undef H5O_SHARED_POST_COPY_FILE_REAL
-#define H5O_SHARED_POST_COPY_FILE_UPD H5O__dtype_shared_post_copy_upd
-#define H5O_SHARED_DEBUG H5O__dtype_shared_debug
-#define H5O_SHARED_DEBUG_REAL H5O__dtype_debug
-#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
+#define H5O_SHARED_COPY_FILE H5O__dtype_shared_copy_file
+#define H5O_SHARED_COPY_FILE_REAL H5O__dtype_copy_file
+#define H5O_SHARED_POST_COPY_FILE H5O__dtype_shared_post_copy_file
+#undef H5O_SHARED_POST_COPY_FILE_REAL
+#define H5O_SHARED_POST_COPY_FILE_UPD H5O__dtype_shared_post_copy_upd
+#define H5O_SHARED_DEBUG H5O__dtype_shared_debug
+#define H5O_SHARED_DEBUG_REAL H5O__dtype_debug
+#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
/* Macros to check for the proper version of a datatype */
#ifdef H5_STRICT_FORMAT_CHECKS
/* If the version is too low, give an error. No error if nochange is set
* because in that case we are either debugging or deleting the object header */
-#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \
- if(((VERS) < (MIN_VERS)) && !(*(IOF) & H5O_DECODEIO_NOCHANGE)) \
+#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \
+ if (((VERS) < (MIN_VERS)) && !(*(IOF)&H5O_DECODEIO_NOCHANGE)) \
HGOTO_ERROR(H5E_DATATYPE, H5E_VERSION, ERR, "incorrect " CLASS " datatype version")
#else /* H5_STRICT_FORMAT_CHECKS */
/* If the version is too low and we are allowed to change the message, upgrade
* it and mark the object header as dirty */
-#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \
- if(((VERS) < (MIN_VERS)) && !(*(IOF) & H5O_DECODEIO_NOCHANGE)) { \
- (VERS) = (MIN_VERS); \
- if(H5T__upgrade_version((DT), (VERS)) < 0) \
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade " CLASS " encoding version") \
- *(IOF) |= H5O_DECODEIO_DIRTY; \
- } /* end if */
+#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \
+ if (((VERS) < (MIN_VERS)) && !(*(IOF)&H5O_DECODEIO_NOCHANGE)) { \
+ (VERS) = (MIN_VERS); \
+ if (H5T__upgrade_version((DT), (VERS)) < 0) \
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade " CLASS " encoding version") \
+ *(IOF) |= H5O_DECODEIO_DIRTY; \
+ } /* end if */
#endif /* H5_STRICT_FORMAT_CHECKS */
/* This message derives from H5O message class */
const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{
- H5O_DTYPE_ID, /* message id number */
- "datatype", /* message name for debugging */
- sizeof(H5T_t), /* native message size */
- H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */
- H5O__dtype_shared_decode, /* decode message */
- H5O__dtype_shared_encode, /* encode message */
- H5O__dtype_copy, /* copy the native value */
- H5O__dtype_shared_size, /* size of raw message */
- H5O__dtype_reset, /* reset method */
- H5O__dtype_free, /* free method */
- H5O__dtype_shared_delete, /* file delete method */
- H5O__dtype_shared_link, /* link method */
- H5O__dtype_set_share, /* set share method */
- H5O__dtype_can_share, /* can share method */
- H5O__dtype_pre_copy_file, /* pre copy native value to file */
- H5O__dtype_shared_copy_file, /* copy native value to file */
- H5O__dtype_shared_post_copy_file, /* post copy native value to file */
- NULL, /* get creation index */
- NULL, /* set creation index */
- H5O__dtype_shared_debug /* debug the message */
+ H5O_DTYPE_ID, /* message id number */
+ "datatype", /* message name for debugging */
+ sizeof(H5T_t), /* native message size */
+ H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */
+ H5O__dtype_shared_decode, /* decode message */
+ H5O__dtype_shared_encode, /* encode message */
+ H5O__dtype_copy, /* copy the native value */
+ H5O__dtype_shared_size, /* size of raw message */
+ H5O__dtype_reset, /* reset method */
+ H5O__dtype_free, /* free method */
+ H5O__dtype_shared_delete, /* file delete method */
+ H5O__dtype_shared_link, /* link method */
+ H5O__dtype_set_share, /* set share method */
+ H5O__dtype_can_share, /* can share method */
+ H5O__dtype_pre_copy_file, /* pre copy native value to file */
+ H5O__dtype_shared_copy_file, /* copy native value to file */
+ H5O__dtype_shared_post_copy_file, /* post copy native value to file */
+ NULL, /* get creation index */
+ NULL, /* set creation index */
+ H5O__dtype_shared_debug /* debug the message */
}};
-
/*-------------------------------------------------------------------------
* Function: H5O__dtype_decode_helper
*
@@ -129,12 +124,12 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{
*-------------------------------------------------------------------------
*/
static htri_t
-H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t *dt)
+H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t *dt)
{
- unsigned flags, version;
- unsigned i;
- size_t z;
- htri_t ret_value = FALSE; /* Return value */
+ unsigned flags, version;
+ unsigned i;
+ size_t z;
+ htri_t ret_value = FALSE; /* Return value */
FUNC_ENTER_STATIC
@@ -144,24 +139,24 @@ H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t
/* Version, class & flags */
UINT32DECODE(*pp, flags);
- version = (flags>>4) & 0x0f;
- if(version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_LATEST)
+ version = (flags >> 4) & 0x0f;
+ if (version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_LATEST)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "bad version number for datatype message")
dt->shared->version = version;
- dt->shared->type = (H5T_class_t)(flags & 0x0f);
+ dt->shared->type = (H5T_class_t)(flags & 0x0f);
flags >>= 8;
/* Size */
UINT32DECODE(*pp, dt->shared->size);
- switch(dt->shared->type) {
+ switch (dt->shared->type) {
case H5T_INTEGER:
/*
* Integer types...
*/
- dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
- dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
- dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
+ dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
dt->shared->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE;
UINT16DECODE(*pp, dt->shared->u.atomic.offset);
UINT16DECODE(*pp, dt->shared->u.atomic.prec);
@@ -172,19 +167,19 @@ H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t
* Floating-point types...
*/
dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
- if(version >= H5O_DTYPE_VERSION_3) {
+ if (version >= H5O_DTYPE_VERSION_3) {
/* Unsupported byte order*/
- if((flags & 0x40) && !(flags & 0x1))
+ if ((flags & 0x40) && !(flags & 0x1))
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bad byte order for datatype message")
/* VAX order if both 1st and 6th bits are turned on*/
- if(flags & 0x40)
+ if (flags & 0x40)
dt->shared->u.atomic.order = H5T_ORDER_VAX;
} /* end if */
dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
dt->shared->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO;
- switch((flags >> 4) & 0x03) {
+ switch ((flags >> 4) & 0x03) {
case 0:
dt->shared->u.atomic.u.f.norm = H5T_NORM_NONE;
break;
@@ -203,16 +198,16 @@ H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t
dt->shared->u.atomic.u.f.sign = (flags >> 8) & 0xff;
UINT16DECODE(*pp, dt->shared->u.atomic.offset);
UINT16DECODE(*pp, dt->shared->u.atomic.prec);
- dt->shared->u.atomic.u.f.epos = *(*pp)++;
+ dt->shared->u.atomic.u.f.epos = *(*pp)++;
dt->shared->u.atomic.u.f.esize = *(*pp)++;
HDassert(dt->shared->u.atomic.u.f.esize > 0);
- dt->shared->u.atomic.u.f.mpos = *(*pp)++;
+ dt->shared->u.atomic.u.f.mpos = *(*pp)++;
dt->shared->u.atomic.u.f.msize = *(*pp)++;
HDassert(dt->shared->u.atomic.u.f.msize > 0);
UINT32DECODE(*pp, dt->shared->u.atomic.u.f.ebias);
break;
- case H5T_TIME: /* Time datatypes */
+ case H5T_TIME: /* Time datatypes */
dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
UINT16DECODE(*pp, dt->shared->u.atomic.prec);
break;
@@ -221,13 +216,13 @@ H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t
/*
* Character string types...
*/
- dt->shared->u.atomic.order = H5T_ORDER_NONE;
- dt->shared->u.atomic.prec = 8 * dt->shared->size;
- dt->shared->u.atomic.offset = 0;
+ dt->shared->u.atomic.order = H5T_ORDER_NONE;
+ dt->shared->u.atomic.prec = 8 * dt->shared->size;
+ dt->shared->u.atomic.offset = 0;
dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;
dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;
- dt->shared->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f);
+ dt->shared->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f);
dt->shared->u.atomic.u.s.cset = (H5T_cset_t)((flags >> 4) & 0x0f);
break;
@@ -235,7 +230,7 @@ H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t
/*
* Bit fields...
*/
- dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
+ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
UINT16DECODE(*pp, dt->shared->u.atomic.offset);
@@ -248,209 +243,214 @@ H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t
*/
z = flags & (H5T_OPAQUE_TAG_MAX - 1);
HDassert(0 == (z & 0x7)); /*must be aligned*/
- if(NULL == (dt->shared->u.opaque.tag = (char *)H5MM_malloc(z + 1)))
+ if (NULL == (dt->shared->u.opaque.tag = (char *)H5MM_malloc(z + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
H5MM_memcpy(dt->shared->u.opaque.tag, *pp, z);
dt->shared->u.opaque.tag[z] = '\0';
*pp += z;
break;
- case H5T_COMPOUND:
- {
- unsigned offset_nbytes; /* Size needed to encode member offsets */
- size_t max_memb_pos = 0; /* Maximum member covered, so far */
- unsigned max_version = 0; /* Maximum member version */
- unsigned upgrade_to = 0; /* Version number we can "soft" upgrade to */
- unsigned j;
+ case H5T_COMPOUND: {
+ unsigned offset_nbytes; /* Size needed to encode member offsets */
+ size_t max_memb_pos = 0; /* Maximum member covered, so far */
+ unsigned max_version = 0; /* Maximum member version */
+ unsigned upgrade_to = 0; /* Version number we can "soft" upgrade to */
+ unsigned j;
- /* Compute the # of bytes required to store a member offset */
- offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size);
+ /* Compute the # of bytes required to store a member offset */
+ offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size);
- /*
- * Compound datatypes...
- */
- dt->shared->u.compnd.nmembs = flags & 0xffff;
- if(dt->shared->u.compnd.nmembs == 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid number of members: %u", dt->shared->u.compnd.nmembs)
- dt->shared->u.compnd.nalloc = dt->shared->u.compnd.nmembs;
- dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_calloc(dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t));
- dt->shared->u.compnd.memb_size = 0;
- if(NULL == dt->shared->u.compnd.memb)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed")
- for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
- unsigned ndims = 0; /* Number of dimensions of the array field */
- htri_t can_upgrade; /* Whether we can upgrade this type's version */
- hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */
- H5T_t *array_dt; /* Temporary pointer to the array datatype */
- H5T_t *temp_type; /* Temporary pointer to the field's datatype */
-
- /* Decode the field name */
- dt->shared->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp);
-
- /* Version 3 of the datatype message eliminated the padding to multiple of 8 bytes */
- if(version >= H5O_DTYPE_VERSION_3)
- /* Advance past name, including null terminator */
- *pp += HDstrlen((const char *)*pp) + 1;
- else
- /* Advance multiple of 8 w/ null terminator */
- *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8;
+ /*
+ * Compound datatypes...
+ */
+ dt->shared->u.compnd.nmembs = flags & 0xffff;
+ if (dt->shared->u.compnd.nmembs == 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid number of members: %u",
+ dt->shared->u.compnd.nmembs)
+ dt->shared->u.compnd.nalloc = dt->shared->u.compnd.nmembs;
+ dt->shared->u.compnd.memb =
+ (H5T_cmemb_t *)H5MM_calloc(dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t));
+ dt->shared->u.compnd.memb_size = 0;
+ if (NULL == dt->shared->u.compnd.memb)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed")
+ for (i = 0; i < dt->shared->u.compnd.nmembs; i++) {
+ unsigned ndims = 0; /* Number of dimensions of the array field */
+ htri_t can_upgrade; /* Whether we can upgrade this type's version */
+ hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */
+ H5T_t * array_dt; /* Temporary pointer to the array datatype */
+ H5T_t * temp_type; /* Temporary pointer to the field's datatype */
+
+ /* Decode the field name */
+ dt->shared->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp);
- /* Decode the field offset */
- /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */
- if(version >= H5O_DTYPE_VERSION_3)
- UINT32DECODE_VAR(*pp, dt->shared->u.compnd.memb[i].offset, offset_nbytes)
- else
- UINT32DECODE(*pp, dt->shared->u.compnd.memb[i].offset)
-
- /* Older versions of the library allowed a field to have
- * intrinsic 'arrayness'. Newer versions of the library
- * use the separate array datatypes. */
- if(version == H5O_DTYPE_VERSION_1) {
- /* Decode the number of dimensions */
- ndims = *(*pp)++;
-
- /* Check that ndims is valid */
- if(ndims > 4)
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid number of dimensions for array")
-
- *pp += 3; /*reserved bytes */
-
- /* Skip dimension permutation */
- *pp += 4;
-
- /* Skip reserved bytes */
- *pp += 4;
-
- /* Decode array dimension sizes */
- for(j = 0; j < 4; j++)
- UINT32DECODE(*pp, dim[j]);
- } /* end if */
-
- /* Allocate space for the field's datatype */
- if(NULL == (temp_type = H5T__alloc()))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-
- /* Decode the field's datatype information */
- if((can_upgrade = H5O__dtype_decode_helper(ioflags, pp, temp_type)) < 0) {
- for(j = 0; j <= i; j++)
- H5MM_xfree(dt->shared->u.compnd.memb[j].name);
- H5MM_xfree(dt->shared->u.compnd.memb);
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type")
- } /* end if */
-
- /* Upgrade the version if we can and it is necessary */
- if(can_upgrade && temp_type->shared->version > version) {
- upgrade_to = temp_type->shared->version;
-
- /* Pass "can_upgrade" flag down to parent type */
- ret_value = TRUE;
- } /* end if */
-
- /* Go create the array datatype now, for older versions of the datatype message */
- if(version == H5O_DTYPE_VERSION_1) {
- /* Check if this member is an array field */
- if(ndims > 0) {
- /* Create the array datatype for the field */
- if((array_dt = H5T__array_create(temp_type, ndims, dim)) == NULL) {
- for(j = 0; j <= i; j++)
- H5MM_xfree(dt->shared->u.compnd.memb[j].name);
- H5MM_xfree(dt->shared->u.compnd.memb);
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype")
- } /* end if */
-
- /* Close the base type for the array */
- (void)H5T_close_real(temp_type);
-
- /* Make the array type the type that is set for the field */
- temp_type = array_dt;
-
- /* Reset array version if NOCHANGE is specified (i.e. h5debug) */
- if(*ioflags & H5O_DECODEIO_NOCHANGE)
- temp_type->shared->version = H5O_DTYPE_VERSION_1;
- else {
- /* Otherwise upgrade the compound version */
- if(upgrade_to < temp_type->shared->version)
- upgrade_to = temp_type->shared->version;
-
- /* Set the return value to indicate that we should freely
- * upgrade parent types */
- ret_value = TRUE;
- } /* end else */
+ /* Version 3 of the datatype message eliminated the padding to multiple of 8 bytes */
+ if (version >= H5O_DTYPE_VERSION_3)
+ /* Advance past name, including null terminator */
+ *pp += HDstrlen((const char *)*pp) + 1;
+ else
+ /* Advance multiple of 8 w/ null terminator */
+ *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8;
+
+ /* Decode the field offset */
+ /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */
+ if (version >= H5O_DTYPE_VERSION_3)
+ UINT32DECODE_VAR(*pp, dt->shared->u.compnd.memb[i].offset, offset_nbytes)
+ else
+ UINT32DECODE(*pp, dt->shared->u.compnd.memb[i].offset)
+
+ /* Older versions of the library allowed a field to have
+ * intrinsic 'arrayness'. Newer versions of the library
+ * use the separate array datatypes. */
+ if (version == H5O_DTYPE_VERSION_1) {
+ /* Decode the number of dimensions */
+ ndims = *(*pp)++;
+
+ /* Check that ndims is valid */
+ if (ndims > 4)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid number of dimensions for array")
+
+ *pp += 3; /*reserved bytes */
+
+ /* Skip dimension permutation */
+ *pp += 4;
+
+ /* Skip reserved bytes */
+ *pp += 4;
+
+ /* Decode array dimension sizes */
+ for (j = 0; j < 4; j++)
+ UINT32DECODE(*pp, dim[j]);
+ } /* end if */
+
+ /* Allocate space for the field's datatype */
+ if (NULL == (temp_type = H5T__alloc()))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /* Decode the field's datatype information */
+ if ((can_upgrade = H5O__dtype_decode_helper(ioflags, pp, temp_type)) < 0) {
+ for (j = 0; j <= i; j++)
+ H5MM_xfree(dt->shared->u.compnd.memb[j].name);
+ H5MM_xfree(dt->shared->u.compnd.memb);
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type")
+ } /* end if */
+
+ /* Upgrade the version if we can and it is necessary */
+ if (can_upgrade && temp_type->shared->version > version) {
+ upgrade_to = temp_type->shared->version;
+
+ /* Pass "can_upgrade" flag down to parent type */
+ ret_value = TRUE;
+ } /* end if */
+
+ /* Go create the array datatype now, for older versions of the datatype message */
+ if (version == H5O_DTYPE_VERSION_1) {
+ /* Check if this member is an array field */
+ if (ndims > 0) {
+ /* Create the array datatype for the field */
+ if ((array_dt = H5T__array_create(temp_type, ndims, dim)) == NULL) {
+ for (j = 0; j <= i; j++)
+ H5MM_xfree(dt->shared->u.compnd.memb[j].name);
+ H5MM_xfree(dt->shared->u.compnd.memb);
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
+ "unable to create array datatype")
} /* end if */
- } /* end if */
-
- /* Keep track of the maximum member version found */
- if(temp_type->shared->version > max_version)
- max_version = temp_type->shared->version;
-
- /*
- * Set the "force conversion" flag if VL datatype fields exist in this
- * type or any component types
- */
- if(temp_type->shared->force_conv == TRUE)
- dt->shared->force_conv = TRUE;
-
- /* Member size */
- dt->shared->u.compnd.memb[i].size = temp_type->shared->size;
- dt->shared->u.compnd.memb_size += temp_type->shared->size;
-
- /* Set the field datatype (finally :-) */
- dt->shared->u.compnd.memb[i].type = temp_type;
-
- /* Check if this field overlaps with a prior field */
- /* (probably indicates that the file is corrupt) */
- if(i > 0 && dt->shared->u.compnd.memb[i].offset < max_memb_pos) {
- for(j = 0; j < i; j++)
- if(dt->shared->u.compnd.memb[i].offset >= dt->shared->u.compnd.memb[j].offset
- && dt->shared->u.compnd.memb[i].offset < (dt->shared->u.compnd.memb[j].offset + dt->shared->u.compnd.memb[j].size))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "member overlaps with previous member")
- } /* end if */
-
- /* Update the maximum member position covered */
- max_memb_pos = MAX(max_memb_pos, (dt->shared->u.compnd.memb[i].offset + dt->shared->u.compnd.memb[i].size));
- } /* end for */
- /* Check if the compound type is packed */
- H5T__update_packed(dt);
-
- /* Upgrade the compound if requested */
- if(version < upgrade_to) {
- version = upgrade_to;
- if(H5T__upgrade_version(dt, upgrade_to) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade compound encoding version")
- /* We won't mark the message dirty since there were no
- * errors in the file, simply type versions that we will no
- * longer encode. */
+ /* Close the base type for the array */
+ (void)H5T_close_real(temp_type);
+
+ /* Make the array type the type that is set for the field */
+ temp_type = array_dt;
+
+ /* Reset array version if NOCHANGE is specified (i.e. h5debug) */
+ if (*ioflags & H5O_DECODEIO_NOCHANGE)
+ temp_type->shared->version = H5O_DTYPE_VERSION_1;
+ else {
+ /* Otherwise upgrade the compound version */
+ if (upgrade_to < temp_type->shared->version)
+ upgrade_to = temp_type->shared->version;
+
+ /* Set the return value to indicate that we should freely
+ * upgrade parent types */
+ ret_value = TRUE;
+ } /* end else */
+ } /* end if */
+ } /* end if */
+
+ /* Keep track of the maximum member version found */
+ if (temp_type->shared->version > max_version)
+ max_version = temp_type->shared->version;
+
+ /*
+ * Set the "force conversion" flag if VL datatype fields exist in this
+ * type or any component types
+ */
+ if (temp_type->shared->force_conv == TRUE)
+ dt->shared->force_conv = TRUE;
+
+ /* Member size */
+ dt->shared->u.compnd.memb[i].size = temp_type->shared->size;
+ dt->shared->u.compnd.memb_size += temp_type->shared->size;
+
+ /* Set the field datatype (finally :-) */
+ dt->shared->u.compnd.memb[i].type = temp_type;
+
+ /* Check if this field overlaps with a prior field */
+ /* (probably indicates that the file is corrupt) */
+ if (i > 0 && dt->shared->u.compnd.memb[i].offset < max_memb_pos) {
+ for (j = 0; j < i; j++)
+ if (dt->shared->u.compnd.memb[i].offset >= dt->shared->u.compnd.memb[j].offset &&
+ dt->shared->u.compnd.memb[i].offset <
+ (dt->shared->u.compnd.memb[j].offset + dt->shared->u.compnd.memb[j].size))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL,
+ "member overlaps with previous member")
} /* end if */
- /* Check that no member of this compound has a version greater
- * than the compound itself. */
- H5O_DTYPE_CHECK_VERSION(dt, version, max_version, ioflags, "compound", FAIL)
- }
- break;
+ /* Update the maximum member position covered */
+ max_memb_pos = MAX(max_memb_pos,
+ (dt->shared->u.compnd.memb[i].offset + dt->shared->u.compnd.memb[i].size));
+ } /* end for */
+
+ /* Check if the compound type is packed */
+ H5T__update_packed(dt);
+
+ /* Upgrade the compound if requested */
+ if (version < upgrade_to) {
+ version = upgrade_to;
+ if (H5T__upgrade_version(dt, upgrade_to) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade compound encoding version")
+ /* We won't mark the message dirty since there were no
+ * errors in the file, simply type versions that we will no
+ * longer encode. */
+ } /* end if */
+
+ /* Check that no member of this compound has a version greater
+ * than the compound itself. */
+ H5O_DTYPE_CHECK_VERSION(dt, version, max_version, ioflags, "compound", FAIL)
+ } break;
case H5T_REFERENCE: /* Reference datatypes... */
- dt->shared->u.atomic.order = H5T_ORDER_NONE;
- dt->shared->u.atomic.prec = 8 * dt->shared->size;
- dt->shared->u.atomic.offset = 0;
+ dt->shared->u.atomic.order = H5T_ORDER_NONE;
+ dt->shared->u.atomic.prec = 8 * dt->shared->size;
+ dt->shared->u.atomic.offset = 0;
dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;
dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;
/* Set reference type */
dt->shared->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f);
- if(dt->shared->u.atomic.u.r.rtype <= H5R_BADTYPE
- || dt->shared->u.atomic.u.r.rtype >= H5R_MAXTYPE)
+ if (dt->shared->u.atomic.u.r.rtype <= H5R_BADTYPE ||
+ dt->shared->u.atomic.u.r.rtype >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "invalid reference type");
/* Set generic flag */
- if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT2
- || dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION2
- || dt->shared->u.atomic.u.r.rtype == H5R_ATTR) {
- dt->shared->u.atomic.u.r.opaque = TRUE;
- dt->shared->u.atomic.u.r.version = (unsigned)((flags >> 4) & 0x0f);
- if(dt->shared->u.atomic.u.r.version != H5R_ENCODE_VERSION)
+ if (dt->shared->u.atomic.u.r.rtype == H5R_OBJECT2 ||
+ dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION2 ||
+ dt->shared->u.atomic.u.r.rtype == H5R_ATTR) {
+ dt->shared->u.atomic.u.r.opaque = TRUE;
+ dt->shared->u.atomic.u.r.version = (unsigned)((flags >> 4) & 0x0f);
+ if (dt->shared->u.atomic.u.r.version != H5R_ENCODE_VERSION)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "reference version does not match");
- } else
+ }
+ else
dt->shared->u.atomic.u.r.opaque = FALSE;
/* This type needs conversion */
@@ -458,7 +458,7 @@ H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t
/* Mark location of this type as undefined for now. The caller
* function should decide the location. */
- if(H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0)
+ if (H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
break;
@@ -467,26 +467,27 @@ H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t
* Enumeration datatypes...
*/
dt->shared->u.enumer.nmembs = dt->shared->u.enumer.nalloc = flags & 0xffff;
- if(NULL == (dt->shared->parent = H5T__alloc()))
+ if (NULL == (dt->shared->parent = H5T__alloc()))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- if(H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0)
+ if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode parent datatype")
/* Check if the parent of this enum has a version greater than the
* enum itself. */
- H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version,
- ioflags, "enum", FAIL)
+ H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, ioflags, "enum", FAIL)
- if(NULL == (dt->shared->u.enumer.name = (char **)H5MM_calloc(dt->shared->u.enumer.nalloc * sizeof(char*))) ||
- NULL == (dt->shared->u.enumer.value = (uint8_t *)H5MM_calloc(dt->shared->u.enumer.nalloc * dt->shared->parent->shared->size)))
+ if (NULL == (dt->shared->u.enumer.name =
+ (char **)H5MM_calloc(dt->shared->u.enumer.nalloc * sizeof(char *))) ||
+ NULL == (dt->shared->u.enumer.value = (uint8_t *)H5MM_calloc(
+ dt->shared->u.enumer.nalloc * dt->shared->parent->shared->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Names */
- for(i = 0; i < dt->shared->u.enumer.nmembs; i++) {
- dt->shared->u.enumer.name[i] = H5MM_xstrdup((const char*)*pp);
+ for (i = 0; i < dt->shared->u.enumer.nmembs; i++) {
+ dt->shared->u.enumer.name[i] = H5MM_xstrdup((const char *)*pp);
/* Version 3 of the datatype message eliminated the padding to multiple of 8 bytes */
- if(version >= H5O_DTYPE_VERSION_3)
+ if (version >= H5O_DTYPE_VERSION_3)
/* Advance past name, including null terminator */
*pp += HDstrlen((const char *)*pp) + 1;
else
@@ -496,79 +497,76 @@ H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t
/* Values */
H5MM_memcpy(dt->shared->u.enumer.value, *pp,
- dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size);
+ dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size);
*pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size;
break;
- case H5T_VLEN: /* Variable length datatypes... */
+ case H5T_VLEN: /* Variable length datatypes... */
/* Set the type of VL information, either sequence or string */
dt->shared->u.vlen.type = (H5T_vlen_type_t)(flags & 0x0f);
- if(dt->shared->u.vlen.type == H5T_VLEN_STRING) {
+ if (dt->shared->u.vlen.type == H5T_VLEN_STRING) {
dt->shared->u.vlen.pad = (H5T_str_t)((flags >> 4) & 0x0f);
dt->shared->u.vlen.cset = (H5T_cset_t)((flags >> 8) & 0x0f);
} /* end if */
/* Decode base type of VL information */
- if(NULL == (dt->shared->parent = H5T__alloc()))
+ if (NULL == (dt->shared->parent = H5T__alloc()))
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed")
- if(H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0)
+ if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type")
/* Check if the parent of this vlen has a version greater than the
* vlen itself. */
- H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version,
- ioflags, "vlen", FAIL)
+ H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, ioflags, "vlen", FAIL)
- dt->shared->force_conv=TRUE;
+ dt->shared->force_conv = TRUE;
/* Mark location this type as undefined for now. The caller function should
* decide the location. */
- if(H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0)
+ if (H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
break;
- case H5T_ARRAY: /* Array datatypes */
+ case H5T_ARRAY: /* Array datatypes */
/* Decode the number of dimensions */
dt->shared->u.array.ndims = *(*pp)++;
/* Double-check the number of dimensions */
- if(dt->shared->u.array.ndims > H5S_MAX_RANK)
+ if (dt->shared->u.array.ndims > H5S_MAX_RANK)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "too many dimensions for array datatype")
/* Skip reserved bytes, if version has them */
- if(version < H5O_DTYPE_VERSION_3)
+ if (version < H5O_DTYPE_VERSION_3)
*pp += 3;
/* Decode array dimension sizes & compute number of elements */
- for(i = 0, dt->shared->u.array.nelem = 1; i < (unsigned)dt->shared->u.array.ndims; i++) {
+ for (i = 0, dt->shared->u.array.nelem = 1; i < (unsigned)dt->shared->u.array.ndims; i++) {
UINT32DECODE(*pp, dt->shared->u.array.dim[i]);
dt->shared->u.array.nelem *= dt->shared->u.array.dim[i];
} /* end for */
/* Skip array dimension permutations, if version has them */
- if(version < H5O_DTYPE_VERSION_3)
+ if (version < H5O_DTYPE_VERSION_3)
*pp += dt->shared->u.array.ndims * 4;
/* Decode base type of array */
- if(NULL == (dt->shared->parent = H5T__alloc()))
+ if (NULL == (dt->shared->parent = H5T__alloc()))
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed")
- if(H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0)
+ if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode array parent type")
/* Check if the parent of this array has a version greater than the
* array itself. */
- H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version,
- ioflags, "array", FAIL)
+ H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, ioflags, "array", FAIL)
/* There should be no array datatypes with version < 2. */
- H5O_DTYPE_CHECK_VERSION(dt, version, H5O_DTYPE_VERSION_2, ioflags,
- "array", FAIL)
+ H5O_DTYPE_CHECK_VERSION(dt, version, H5O_DTYPE_VERSION_2, ioflags, "array", FAIL)
/*
* Set the "force conversion" flag if a VL base datatype is used or
* or if any components of the base datatype are VL types.
*/
- if(dt->shared->parent->shared->force_conv == TRUE)
+ if (dt->shared->parent->shared->force_conv == TRUE)
dt->shared->force_conv = TRUE;
break;
@@ -579,9 +577,9 @@ H5O__dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t
} /* end switch */
done:
- if(ret_value < 0)
- if(dt != NULL) {
- if(dt->shared != NULL)
+ if (ret_value < 0)
+ if (dt != NULL) {
+ if (dt->shared != NULL)
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
dt = H5FL_FREE(H5T_t, dt);
} /* end if */
@@ -589,7 +587,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_decode_helper() */
-
/*-------------------------------------------------------------------------
* Function: H5O__dtype_encode_helper
*
@@ -609,11 +606,11 @@ done:
static herr_t
H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
{
- unsigned flags = 0;
- uint8_t *hdr = (uint8_t *)*pp;
- unsigned i;
- size_t n, z;
- herr_t ret_value = SUCCEED; /* Return value */
+ unsigned flags = 0;
+ uint8_t *hdr = (uint8_t *)*pp;
+ unsigned i;
+ size_t n, z;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -625,14 +622,14 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
*pp += 4;
UINT32ENCODE(*pp, dt->shared->size);
- switch(dt->shared->type) {
+ switch (dt->shared->type) {
case H5T_INTEGER:
/*
* Integer datatypes...
*/
switch (dt->shared->u.atomic.order) {
case H5T_ORDER_LE:
- break; /*nothing */
+ break; /*nothing */
case H5T_ORDER_BE:
flags |= 0x01;
@@ -643,12 +640,13 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_ORDER_MIXED:
case H5T_ORDER_NONE:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "byte order is not supported in file format yet")
} /* end switch */
switch (dt->shared->u.atomic.lsb_pad) {
case H5T_PAD_ZERO:
- break; /*nothing */
+ break; /*nothing */
case H5T_PAD_ONE:
flags |= 0x02;
@@ -658,12 +656,13 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_PAD_BACKGROUND:
case H5T_NPAD:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet")
} /* end switch */
switch (dt->shared->u.atomic.msb_pad) {
case H5T_PAD_ZERO:
- break; /*nothing */
+ break; /*nothing */
case H5T_PAD_ERROR:
case H5T_PAD_BACKGROUND:
@@ -673,12 +672,13 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet")
} /* end switch */
switch (dt->shared->u.atomic.u.i.sign) {
case H5T_SGN_NONE:
- break; /*nothing */
+ break; /*nothing */
case H5T_SGN_2:
flags |= 0x08;
@@ -687,7 +687,8 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_SGN_ERROR:
case H5T_NSGN:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "sign scheme is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "sign scheme is not supported in file format yet")
} /* end switch */
UINT16ENCODE(*pp, dt->shared->u.atomic.offset);
@@ -700,13 +701,13 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
*/
switch (dt->shared->u.atomic.order) {
case H5T_ORDER_LE:
- break; /*nothing*/
+ break; /*nothing*/
case H5T_ORDER_BE:
flags |= 0x01;
break;
- case H5T_ORDER_VAX: /*turn on 1st and 6th (reserved before adding VAX) bits*/
+ case H5T_ORDER_VAX: /*turn on 1st and 6th (reserved before adding VAX) bits*/
flags |= 0x41;
HDassert(dt->shared->version >= H5O_DTYPE_VERSION_3);
break;
@@ -715,12 +716,13 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_ORDER_ERROR:
case H5T_ORDER_NONE:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "byte order is not supported in file format yet")
} /* end switch */
switch (dt->shared->u.atomic.lsb_pad) {
case H5T_PAD_ZERO:
- break; /*nothing */
+ break; /*nothing */
case H5T_PAD_ONE:
flags |= 0x02;
@@ -730,12 +732,13 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_PAD_BACKGROUND:
case H5T_NPAD:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet")
} /* end switch */
switch (dt->shared->u.atomic.msb_pad) {
case H5T_PAD_ZERO:
- break; /*nothing */
+ break; /*nothing */
case H5T_PAD_ONE:
flags |= 0x04;
@@ -745,12 +748,13 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_PAD_BACKGROUND:
case H5T_NPAD:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet")
} /* end switch */
switch (dt->shared->u.atomic.u.f.pad) {
case H5T_PAD_ZERO:
- break; /*nothing */
+ break; /*nothing */
case H5T_PAD_ONE:
flags |= 0x08;
@@ -760,12 +764,13 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_PAD_BACKGROUND:
case H5T_NPAD:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet")
} /* end switch */
switch (dt->shared->u.atomic.u.f.norm) {
case H5T_NORM_NONE:
- break; /*nothing */
+ break; /*nothing */
case H5T_NORM_MSBSET:
flags |= 0x10;
@@ -777,7 +782,8 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_NORM_ERROR:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "normalization scheme is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "normalization scheme is not supported in file format yet")
} /* end switch */
flags = (unsigned)(flags | ((dt->shared->u.atomic.u.f.sign << 8) & 0xff00));
@@ -794,10 +800,10 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
UINT32ENCODE(*pp, dt->shared->u.atomic.u.f.ebias);
break;
- case H5T_TIME: /* Time datatypes... */
+ case H5T_TIME: /* Time datatypes... */
switch (dt->shared->u.atomic.order) {
case H5T_ORDER_LE:
- break; /*nothing */
+ break; /*nothing */
case H5T_ORDER_BE:
flags |= 0x01;
@@ -808,7 +814,8 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_ORDER_ERROR:
case H5T_ORDER_NONE:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "byte order is not supported in file format yet")
} /* end switch */
UINT16ENCODE(*pp, dt->shared->u.atomic.prec);
break;
@@ -833,7 +840,7 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
*/
switch (dt->shared->u.atomic.order) {
case H5T_ORDER_LE:
- break; /*nothing */
+ break; /*nothing */
case H5T_ORDER_BE:
flags |= 0x01;
@@ -844,12 +851,13 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_ORDER_ERROR:
case H5T_ORDER_NONE:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "byte order is not supported in file format yet")
} /* end switch */
switch (dt->shared->u.atomic.lsb_pad) {
case H5T_PAD_ZERO:
- break; /*nothing */
+ break; /*nothing */
case H5T_PAD_ONE:
flags |= 0x02;
@@ -859,12 +867,13 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_PAD_BACKGROUND:
case H5T_NPAD:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet")
} /* end switch */
switch (dt->shared->u.atomic.msb_pad) {
case H5T_PAD_ZERO:
- break; /*nothing */
+ break; /*nothing */
case H5T_PAD_ONE:
flags |= 0x04;
@@ -874,7 +883,8 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_PAD_BACKGROUND:
case H5T_NPAD:
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet")
} /* end switch */
UINT16ENCODE(*pp, dt->shared->u.atomic.offset);
@@ -888,94 +898,93 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
* null terminated).
*/
{
- size_t aligned;
+ size_t aligned;
- z = HDstrlen(dt->shared->u.opaque.tag);
+ z = HDstrlen(dt->shared->u.opaque.tag);
aligned = (z + 7) & (H5T_OPAQUE_TAG_MAX - 8);
- flags = (unsigned)(flags | aligned);
- H5MM_memcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned));
- for(n = MIN(z, aligned); n < aligned; n++)
+ flags = (unsigned)(flags | aligned);
+ H5MM_memcpy(*pp, dt->shared->u.opaque.tag, MIN(z, aligned));
+ for (n = MIN(z, aligned); n < aligned; n++)
(*pp)[n] = 0;
*pp += aligned;
}
break;
- case H5T_COMPOUND:
- {
- unsigned offset_nbytes; /* Size needed to encode member offsets */
+ case H5T_COMPOUND: {
+ unsigned offset_nbytes; /* Size needed to encode member offsets */
- /* Compute the # of bytes required to store a member offset */
- offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size);
+ /* Compute the # of bytes required to store a member offset */
+ offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size);
- /*
- * Compound datatypes...
+ /*
+ * Compound datatypes...
+ */
+ flags = dt->shared->u.compnd.nmembs & 0xffff;
+ for (i = 0; i < dt->shared->u.compnd.nmembs; i++) {
+ /* Sanity check */
+ /* (compound datatypes w/array members must be encoded w/version >= 2) */
+ HDassert(dt->shared->u.compnd.memb[i].type->shared->type != H5T_ARRAY ||
+ dt->shared->version >= H5O_DTYPE_VERSION_2);
+
+ /* Check that the version is at least as great as the member */
+ HDassert(dt->shared->version >= dt->shared->u.compnd.memb[i].type->shared->version);
+
+ /* Name */
+ HDstrcpy((char *)(*pp), dt->shared->u.compnd.memb[i].name);
+
+ /* Version 3 of the datatype message removed the padding to multiple of 8 bytes */
+ n = HDstrlen(dt->shared->u.compnd.memb[i].name);
+ if (dt->shared->version >= H5O_DTYPE_VERSION_3)
+ *pp += n + 1;
+ else {
+ /* Pad name to multiple of 8 bytes */
+ for (z = n + 1; z % 8; z++)
+ (*pp)[z] = '\0';
+ *pp += z;
+ } /* end if */
+
+ /* Member offset */
+ /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */
+ if (dt->shared->version >= H5O_DTYPE_VERSION_3)
+ UINT32ENCODE_VAR(*pp, (uint32_t)dt->shared->u.compnd.memb[i].offset, offset_nbytes)
+ else
+ UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset)
+
+ /* If we don't have any array fields, write out the old style
+ * member information, for better backward compatibility
+ * Write out all zeros for the array information, though...
*/
- flags = dt->shared->u.compnd.nmembs & 0xffff;
- for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
- /* Sanity check */
- /* (compound datatypes w/array members must be encoded w/version >= 2) */
- HDassert(dt->shared->u.compnd.memb[i].type->shared->type != H5T_ARRAY || dt->shared->version >= H5O_DTYPE_VERSION_2);
-
- /* Check that the version is at least as great as the member */
- HDassert(dt->shared->version >= dt->shared->u.compnd.memb[i].type->shared->version);
-
- /* Name */
- HDstrcpy((char*)(*pp), dt->shared->u.compnd.memb[i].name);
-
- /* Version 3 of the datatype message removed the padding to multiple of 8 bytes */
- n = HDstrlen(dt->shared->u.compnd.memb[i].name);
- if(dt->shared->version >= H5O_DTYPE_VERSION_3)
- *pp += n + 1;
- else {
- /* Pad name to multiple of 8 bytes */
- for(z = n + 1; z % 8; z++)
- (*pp)[z] = '\0';
- *pp += z;
- } /* end if */
-
- /* Member offset */
- /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */
- if(dt->shared->version >= H5O_DTYPE_VERSION_3)
- UINT32ENCODE_VAR(*pp, (uint32_t)dt->shared->u.compnd.memb[i].offset, offset_nbytes)
- else
- UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset)
+ if (dt->shared->version == H5O_DTYPE_VERSION_1) {
+ unsigned j;
- /* If we don't have any array fields, write out the old style
- * member information, for better backward compatibility
- * Write out all zeros for the array information, though...
- */
- if(dt->shared->version == H5O_DTYPE_VERSION_1) {
- unsigned j;
+ /* Dimensionality */
+ *(*pp)++ = 0;
- /* Dimensionality */
- *(*pp)++ = 0;
+ /* Reserved */
+ *(*pp)++ = 0;
+ *(*pp)++ = 0;
+ *(*pp)++ = 0;
- /* Reserved */
- *(*pp)++ = 0;
- *(*pp)++ = 0;
- *(*pp)++ = 0;
+ /* Dimension permutation */
+ UINT32ENCODE(*pp, 0);
- /* Dimension permutation */
- UINT32ENCODE(*pp, 0);
+ /* Reserved */
+ UINT32ENCODE(*pp, 0);
- /* Reserved */
+ /* Dimensions */
+ for (j = 0; j < 4; j++)
UINT32ENCODE(*pp, 0);
+ } /* end if */
- /* Dimensions */
- for(j = 0; j < 4; j++)
- UINT32ENCODE(*pp, 0);
- } /* end if */
-
- /* Subtype */
- if(H5O__dtype_encode_helper(pp, dt->shared->u.compnd.memb[i].type) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type")
- } /* end for */
- }
- break;
+ /* Subtype */
+ if (H5O__dtype_encode_helper(pp, dt->shared->u.compnd.memb[i].type) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type")
+ } /* end for */
+ } break;
case H5T_REFERENCE:
flags |= (dt->shared->u.atomic.u.r.rtype & 0x0f);
- if(dt->shared->u.atomic.u.r.opaque)
+ if (dt->shared->u.atomic.u.r.opaque)
flags = (unsigned)(flags | (((unsigned)dt->shared->u.atomic.u.r.version & 0x0f) << 4));
break;
@@ -989,47 +998,48 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags = dt->shared->u.enumer.nmembs & 0xffff;
/* Parent type */
- if(H5O__dtype_encode_helper(pp, dt->shared->parent) < 0)
+ if (H5O__dtype_encode_helper(pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode parent datatype")
/* Names, each a multiple of eight bytes */
- for(i = 0; i < dt->shared->u.enumer.nmembs; i++) {
+ for (i = 0; i < dt->shared->u.enumer.nmembs; i++) {
/* Name */
- HDstrcpy((char*)(*pp), dt->shared->u.enumer.name[i]);
+ HDstrcpy((char *)(*pp), dt->shared->u.enumer.name[i]);
/* Version 3 of the datatype message removed the padding to multiple of 8 bytes */
n = HDstrlen(dt->shared->u.enumer.name[i]);
- if(dt->shared->version >= H5O_DTYPE_VERSION_3)
+ if (dt->shared->version >= H5O_DTYPE_VERSION_3)
*pp += n + 1;
else {
/* Pad to multiple of 8 bytes */
- for(z = n + 1; z % 8; z++)
+ for (z = n + 1; z % 8; z++)
(*pp)[z] = '\0';
*pp += z;
} /* end for */
- } /* end for */
+ } /* end for */
/* Values */
- H5MM_memcpy(*pp, dt->shared->u.enumer.value, dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size);
+ H5MM_memcpy(*pp, dt->shared->u.enumer.value,
+ dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size);
*pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size;
break;
- case H5T_VLEN: /* Variable length datatypes... */
+ case H5T_VLEN: /* Variable length datatypes... */
/* Check that the version is at least as great as the parent */
HDassert(dt->shared->version >= dt->shared->parent->shared->version);
flags |= (dt->shared->u.vlen.type & 0x0f);
- if(dt->shared->u.vlen.type == H5T_VLEN_STRING) {
- flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.pad & 0x0f) << 4));
- flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.cset & 0x0f) << 8));
+ if (dt->shared->u.vlen.type == H5T_VLEN_STRING) {
+ flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.pad & 0x0f) << 4));
+ flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.cset & 0x0f) << 8));
} /* end if */
/* Encode base type of VL information */
- if(H5O__dtype_encode_helper(pp, dt->shared->parent) < 0)
+ if (H5O__dtype_encode_helper(pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type")
break;
- case H5T_ARRAY: /* Array datatypes */
+ case H5T_ARRAY: /* Array datatypes */
/* Double-check the number of dimensions */
HDassert(dt->shared->u.array.ndims <= H5S_MAX_RANK);
@@ -1044,7 +1054,7 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
*(*pp)++ = (uint8_t)dt->shared->u.array.ndims;
/* Drop this information for Version 3 of the format */
- if(dt->shared->version < H5O_DTYPE_VERSION_3) {
+ if (dt->shared->version < H5O_DTYPE_VERSION_3) {
/* Reserved */
*(*pp)++ = '\0';
*(*pp)++ = '\0';
@@ -1052,18 +1062,18 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
} /* end if */
/* Encode array dimensions */
- for(i = 0; i < (unsigned)dt->shared->u.array.ndims; i++)
+ for (i = 0; i < (unsigned)dt->shared->u.array.ndims; i++)
UINT32ENCODE(*pp, dt->shared->u.array.dim[i]);
/* Drop this information for Version 3 of the format */
- if(dt->shared->version < H5O_DTYPE_VERSION_3) {
+ if (dt->shared->version < H5O_DTYPE_VERSION_3) {
/* Encode 'fake' array dimension permutations */
- for(i = 0; i < (unsigned)dt->shared->u.array.ndims; i++)
+ for (i = 0; i < (unsigned)dt->shared->u.array.ndims; i++)
UINT32ENCODE(*pp, i);
} /* end if */
/* Encode base type of array's information */
- if(H5O__dtype_encode_helper(pp, dt->shared->parent) < 0)
+ if (H5O__dtype_encode_helper(pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type")
break;
@@ -1084,13 +1094,12 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_encode_helper() */
-
/*--------------------------------------------------------------------------
NAME
H5O__dtype_decode
PURPOSE
Decode a message and return a pointer to a memory struct
- with the decoded information
+ with the decoded information
USAGE
void *H5O__dtype_decode(f, mesg_flags, p)
H5F_t *f; IN: pointer to the HDF5 file struct
@@ -1102,16 +1111,16 @@ done:
RETURNS
Pointer to the new message in native order on success, NULL on failure
DESCRIPTION
- This function decodes the "raw" disk form of a simple datatype message
+ This function decodes the "raw" disk form of a simple datatype message
into a struct in memory native format. The struct is allocated within this
function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
H5O__dtype_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
- unsigned *ioflags/*in,out*/, size_t H5_ATTR_UNUSED p_size, const uint8_t *p)
+ unsigned *ioflags /*in,out*/, size_t H5_ATTR_UNUSED p_size, const uint8_t *p)
{
- H5T_t *dt = NULL;
- void *ret_value = NULL; /* Return value */
+ H5T_t *dt = NULL;
+ void * ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@@ -1119,11 +1128,11 @@ H5O__dtype_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign
HDassert(p);
/* Allocate datatype message */
- if(NULL == (dt = H5T__alloc()))
+ if (NULL == (dt = H5T__alloc()))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Perform actual decode of message */
- if(H5O__dtype_decode_helper(ioflags, &p, dt) < 0)
+ if (H5O__dtype_decode_helper(ioflags, &p, dt) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode type")
/* Set return value */
@@ -1133,7 +1142,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_decode() */
-
/*--------------------------------------------------------------------------
NAME
H5O__dtype_encode
@@ -1141,21 +1149,21 @@ done:
Encode a simple datatype message
USAGE
herr_t H5O__dtype_encode(f, raw_size, p, mesg)
- H5F_t *f; IN: pointer to the HDF5 file struct
- size_t raw_size; IN: size of the raw information buffer
- const uint8 *p; IN: the raw information buffer
- const void *mesg; IN: Pointer to the simple datatype struct
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ size_t raw_size; IN: size of the raw information buffer
+ const uint8 *p; IN: the raw information buffer
+ const void *mesg; IN: Pointer to the simple datatype struct
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
- This function encodes the native memory form of the simple datatype
+ This function encodes the native memory form of the simple datatype
message in the "raw" disk form.
--------------------------------------------------------------------------*/
static herr_t
H5O__dtype_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *mesg)
{
- const H5T_t *dt = (const H5T_t *) mesg;
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5T_t *dt = (const H5T_t *)mesg;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1165,14 +1173,13 @@ H5O__dtype_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *mesg)
HDassert(dt);
/* encode */
- if(H5O__dtype_encode_helper(&p, dt) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type")
+ if (H5O__dtype_encode_helper(&p, dt) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_encode() */
-
/*--------------------------------------------------------------------------
NAME
H5O__dtype_copy
@@ -1180,22 +1187,22 @@ done:
Copies a message from MESG to DEST, allocating DEST if necessary.
USAGE
void *H5O__dtype_copy(mesg, dest)
- const void *mesg; IN: Pointer to the source simple datatype
- struct
- const void *dest; IN: Pointer to the destination simple
- datatype struct
+ const void *mesg; IN: Pointer to the source simple datatype
+ struct
+ const void *dest; IN: Pointer to the destination simple
+ datatype struct
RETURNS
Pointer to DEST on success, NULL on failure
DESCRIPTION
- This function copies a native (memory) simple datatype message,
+ This function copies a native (memory) simple datatype message,
allocating the destination structure if necessary.
--------------------------------------------------------------------------*/
static void *
H5O__dtype_copy(const void *_src, void *_dst)
{
- const H5T_t *src = (const H5T_t *) _src;
- H5T_t *dst;
- void *ret_value = NULL; /* Return value */
+ const H5T_t *src = (const H5T_t *)_src;
+ H5T_t * dst;
+ void * ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@@ -1203,14 +1210,14 @@ H5O__dtype_copy(const void *_src, void *_dst)
HDassert(src);
/* Copy */
- if(NULL == (dst = H5T_copy(src, H5T_COPY_ALL)))
+ if (NULL == (dst = H5T_copy(src, H5T_COPY_ALL)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type")
/* Was result already allocated? */
- if(_dst) {
- *((H5T_t *) _dst) = *dst;
- dst = H5FL_FREE(H5T_t, dst);
- dst = (H5T_t *) _dst;
+ if (_dst) {
+ *((H5T_t *)_dst) = *dst;
+ dst = H5FL_FREE(H5T_t, dst);
+ dst = (H5T_t *)_dst;
} /* end if */
/* Set return value */
@@ -1220,7 +1227,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_copy() */
-
/*--------------------------------------------------------------------------
NAME
H5O__dtype_size
@@ -1228,21 +1234,21 @@ done:
Return the raw message size in bytes
USAGE
void *H5O__dtype_size(f, mesg)
- H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source simple datatype struct
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ const void *mesg; IN: Pointer to the source simple datatype struct
RETURNS
Size of message on success, 0 on failure
DESCRIPTION
- This function returns the size of the raw simple datatype message on
+ This function returns the size of the raw simple datatype message on
success. (Not counting the message type or size fields, only the data
portion of the message). It doesn't take into account alignment.
--------------------------------------------------------------------------*/
static size_t
H5O__dtype_size(const H5F_t *f, const void *_mesg)
{
- const H5T_t *dt = (const H5T_t *)_mesg;
- unsigned u; /* Local index variable */
- size_t ret_value = 0; /* Return value */
+ const H5T_t *dt = (const H5T_t *)_mesg;
+ unsigned u; /* Local index variable */
+ size_t ret_value = 0; /* Return value */
FUNC_ENTER_STATIC_NOERR
@@ -1250,11 +1256,11 @@ H5O__dtype_size(const H5F_t *f, const void *_mesg)
HDassert(dt);
/* Set the common size information */
- ret_value = 4 + /* Type, class & flags */
- 4; /* Size of datatype */
+ ret_value = 4 + /* Type, class & flags */
+ 4; /* Size of datatype */
/* Add in the property field length for each datatype class */
- switch(dt->shared->type) {
+ switch (dt->shared->type) {
case H5T_INTEGER:
ret_value += 4;
break;
@@ -1275,54 +1281,52 @@ H5O__dtype_size(const H5F_t *f, const void *_mesg)
ret_value += (HDstrlen(dt->shared->u.opaque.tag) + 7) & (H5T_OPAQUE_TAG_MAX - 8);
break;
- case H5T_COMPOUND:
- {
- unsigned offset_nbytes; /* Size needed to encode member offsets */
+ case H5T_COMPOUND: {
+ unsigned offset_nbytes; /* Size needed to encode member offsets */
- /* Compute the # of bytes required to store a member offset */
- offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size);
+ /* Compute the # of bytes required to store a member offset */
+ offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size);
- /* Compute the total size needed to encode compound datatype */
- for(u = 0; u < dt->shared->u.compnd.nmembs; u++) {
- size_t name_len; /* Length of field's name */
+ /* Compute the total size needed to encode compound datatype */
+ for (u = 0; u < dt->shared->u.compnd.nmembs; u++) {
+ size_t name_len; /* Length of field's name */
- /* Get length of field's name */
- name_len = HDstrlen(dt->shared->u.compnd.memb[u].name);
+ /* Get length of field's name */
+ name_len = HDstrlen(dt->shared->u.compnd.memb[u].name);
- /* Versions of the format >= 3 don't pad out the name */
- if(dt->shared->version >= H5O_DTYPE_VERSION_3)
- ret_value += name_len + 1;
- else
- ret_value += ((name_len + 8) / 8) * 8;
-
- /* Check for encoding array datatype or using the latest file format */
- /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */
- if(dt->shared->version >= H5O_DTYPE_VERSION_3)
- ret_value += offset_nbytes; /*member offset*/
- else if(dt->shared->version == H5O_DTYPE_VERSION_2)
- ret_value += 4; /*member offset*/
- else
- ret_value += 4 + /*member offset*/
- 1 + /*dimensionality*/
- 3 + /*reserved*/
- 4 + /*permutation*/
- 4 + /*reserved*/
- 16; /*dimensions*/
- ret_value += H5O__dtype_size(f, dt->shared->u.compnd.memb[u].type);
- } /* end for */
- }
- break;
+ /* Versions of the format >= 3 don't pad out the name */
+ if (dt->shared->version >= H5O_DTYPE_VERSION_3)
+ ret_value += name_len + 1;
+ else
+ ret_value += ((name_len + 8) / 8) * 8;
+
+ /* Check for encoding array datatype or using the latest file format */
+ /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */
+ if (dt->shared->version >= H5O_DTYPE_VERSION_3)
+ ret_value += offset_nbytes; /*member offset*/
+ else if (dt->shared->version == H5O_DTYPE_VERSION_2)
+ ret_value += 4; /*member offset*/
+ else
+ ret_value += 4 + /*member offset*/
+ 1 + /*dimensionality*/
+ 3 + /*reserved*/
+ 4 + /*permutation*/
+ 4 + /*reserved*/
+ 16; /*dimensions*/
+ ret_value += H5O__dtype_size(f, dt->shared->u.compnd.memb[u].type);
+ } /* end for */
+ } break;
case H5T_ENUM:
ret_value += H5O__dtype_size(f, dt->shared->parent);
- for(u = 0; u < dt->shared->u.enumer.nmembs; u++) {
- size_t name_len; /* Length of field's name */
+ for (u = 0; u < dt->shared->u.enumer.nmembs; u++) {
+ size_t name_len; /* Length of field's name */
/* Get length of field's name */
name_len = HDstrlen(dt->shared->u.enumer.name[u]);
/* Versions of the format >= 3 don't pad out the name */
- if(dt->shared->version >= H5O_DTYPE_VERSION_3)
+ if (dt->shared->version >= H5O_DTYPE_VERSION_3)
ret_value += name_len + 1;
else
ret_value += ((name_len + 8) / 8) * 8;
@@ -1336,10 +1340,10 @@ H5O__dtype_size(const H5F_t *f, const void *_mesg)
case H5T_ARRAY:
ret_value += 1; /* ndims */
- if(dt->shared->version < H5O_DTYPE_VERSION_3)
- ret_value += 3; /* reserved bytes*/
+ if (dt->shared->version < H5O_DTYPE_VERSION_3)
+ ret_value += 3; /* reserved bytes*/
ret_value += 4 * dt->shared->u.array.ndims; /* dimensions */
- if(dt->shared->version < H5O_DTYPE_VERSION_3)
+ if (dt->shared->version < H5O_DTYPE_VERSION_3)
ret_value += 4 * dt->shared->u.array.ndims; /* dimension permutations */
ret_value += H5O__dtype_size(f, dt->shared->parent);
break;
@@ -1356,7 +1360,6 @@ H5O__dtype_size(const H5F_t *f, const void *_mesg)
FUNC_LEAVE_NOAPI(ret_value)
} /* H5O__dtype_size() */
-
/*-------------------------------------------------------------------------
* Function: H5O__dtype_reset
*
@@ -1373,17 +1376,16 @@ H5O__dtype_size(const H5F_t *f, const void *_mesg)
static herr_t
H5O__dtype_reset(void *_mesg)
{
- H5T_t *dt = (H5T_t *) _mesg;
+ H5T_t *dt = (H5T_t *)_mesg;
FUNC_ENTER_STATIC_NOERR
- if(dt)
+ if (dt)
H5T__free(dt);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O__dtype_reset() */
-
/*-------------------------------------------------------------------------
* Function: H5O__dtype_free
*
@@ -1399,7 +1401,7 @@ H5O__dtype_reset(void *_mesg)
static herr_t
H5O__dtype_free(void *mesg)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1407,14 +1409,13 @@ H5O__dtype_free(void *mesg)
HDassert(mesg);
/* Release the datatype */
- if(H5T_close_real((H5T_t *)mesg) < 0)
+ if (H5T_close_real((H5T_t *)mesg) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free datatype")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_free() */
-
/*-------------------------------------------------------------------------
* Function: H5O__dtype_set_share
*
@@ -1428,9 +1429,9 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O__dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh)
+H5O__dtype_set_share(void *_mesg /*in,out*/, const H5O_shared_t *sh)
{
- H5T_t *dt = (H5T_t *)_mesg;
+ H5T_t *dt = (H5T_t *)_mesg;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
@@ -1445,18 +1446,18 @@ H5O__dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh)
/* Make sure we're not sharing a committed type in the heap */
HDassert(sh->type == H5O_SHARE_TYPE_COMMITTED ||
- (dt->shared->state != H5T_STATE_OPEN && dt->shared->state != H5T_STATE_NAMED));
+ (dt->shared->state != H5T_STATE_OPEN && dt->shared->state != H5T_STATE_NAMED));
/* Copy the shared information */
- if(H5O_set_shared(&(dt->sh_loc), sh) < 0)
+ if (H5O_set_shared(&(dt->sh_loc), sh) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy shared message info")
/* If this is now a committed datatype, set its state properly. */
- if(sh->type == H5O_SHARE_TYPE_COMMITTED) {
+ if (sh->type == H5O_SHARE_TYPE_COMMITTED) {
dt->shared->state = H5T_STATE_NAMED;
/* Set up the object location for the datatype also */
- if(H5O_loc_reset(&(dt->oloc)) < 0)
+ if (H5O_loc_reset(&(dt->oloc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to reset location")
dt->oloc.file = sh->file;
dt->oloc.addr = sh->u.loc.oh_addr;
@@ -1466,7 +1467,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_set_share() */
-
/*-------------------------------------------------------------------------
* Function: H5O__dtype_can_share
*
@@ -1486,31 +1486,30 @@ done:
static htri_t
H5O__dtype_can_share(const void *_mesg)
{
- const H5T_t *mesg = (const H5T_t *)_mesg;
- htri_t tri_ret;
- htri_t ret_value = TRUE;
+ const H5T_t *mesg = (const H5T_t *)_mesg;
+ htri_t tri_ret;
+ htri_t ret_value = TRUE;
FUNC_ENTER_STATIC
HDassert(mesg);
/* Don't share immutable datatypes */
- if((tri_ret = H5T_is_immutable(mesg)) > 0)
+ if ((tri_ret = H5T_is_immutable(mesg)) > 0)
HGOTO_DONE(FALSE)
- else if(tri_ret < 0)
+ else if (tri_ret < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is immutable")
/* Don't share committed datatypes */
- if((tri_ret = H5T_is_named(mesg)) > 0)
+ if ((tri_ret = H5T_is_named(mesg)) > 0)
HGOTO_DONE(FALSE)
- else if(tri_ret < 0)
+ else if (tri_ret < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is shared")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_can_share() */
-
/*-------------------------------------------------------------------------
* Function: H5O__dtype_pre_copy_file
*
@@ -1527,13 +1526,12 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O__dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src,
- hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info,
- void *_udata)
+H5O__dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t H5_ATTR_UNUSED *deleted,
+ const H5O_copy_t *cpy_info, void *_udata)
{
- const H5T_t *dt_src = (const H5T_t *)mesg_src; /* Source datatype */
- H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5T_t * dt_src = (const H5T_t *)mesg_src; /* Source datatype */
+ H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1545,7 +1543,7 @@ H5O__dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src,
/* Check to ensure that the version of the message to be copied does not exceed
the message version as indicated by the destination file's high bound */
- if(dt_src->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)])
+ if (dt_src->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)])
HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "datatype message version out of bounds")
/* If the user data is non-NULL, assume we are copying a dataset
@@ -1555,13 +1553,13 @@ H5O__dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src,
* message is an early version, but since the layout information isn't
* available here, we just make a copy in all situations)
*/
- if(udata) {
+ if (udata) {
/* Create a memory copy of the variable-length datatype */
- if(NULL == (udata->src_dtype = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
+ if (NULL == (udata->src_dtype = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
/* Set the location of the source datatype to describe the disk form of the data */
- if(H5T_set_loc(udata->src_dtype, H5F_VOL_OBJ(file_src), H5T_LOC_DISK) < 0)
+ if (H5T_set_loc(udata->src_dtype, H5F_VOL_OBJ(file_src), H5T_LOC_DISK) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
} /* end if */
@@ -1569,7 +1567,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_pre_copy_file() */
-
/*-------------------------------------------------------------------------
* Function: H5O__dtype_copy_file
*
@@ -1584,33 +1581,32 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O__dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg_type,
- void *native_src, H5F_t *file_dst, hbool_t H5_ATTR_UNUSED *recompute_size,
- H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata)
+H5O__dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg_type, void *native_src,
+ H5F_t *file_dst, hbool_t H5_ATTR_UNUSED *recompute_size,
+ H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata)
{
- H5T_t *dst_mesg; /* Destination datatype */
- void *ret_value = NULL; /* Return value */
+ H5T_t *dst_mesg; /* Destination datatype */
+ void * ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
/* Perform a normal copy of the object header message */
- if(NULL == (dst_mesg = (H5T_t *)H5O__dtype_copy(native_src, NULL)))
+ if (NULL == (dst_mesg = (H5T_t *)H5O__dtype_copy(native_src, NULL)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy")
/* The datatype will be in the new file; set its location. */
- if(H5T_set_loc(dst_mesg, H5F_VOL_OBJ(file_dst), H5T_LOC_DISK) < 0)
+ if (H5T_set_loc(dst_mesg, H5F_VOL_OBJ(file_dst), H5T_LOC_DISK) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to set location")
ret_value = dst_mesg;
done:
- if(NULL == ret_value)
+ if (NULL == ret_value)
H5O_msg_free(mesg_type->id, dst_mesg);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_copy_file() */
-
/*-------------------------------------------------------------------------
* Function: H5O__dtype_shared_post_copy_upd
*
@@ -1625,18 +1621,18 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O__dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc,
- const void H5_ATTR_UNUSED *mesg_src, H5O_loc_t H5_ATTR_UNUSED *dst_oloc, void *mesg_dst,
- H5O_copy_t H5_ATTR_UNUSED *cpy_info)
+H5O__dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc, const void H5_ATTR_UNUSED *mesg_src,
+ H5O_loc_t H5_ATTR_UNUSED *dst_oloc, void *mesg_dst,
+ H5O_copy_t H5_ATTR_UNUSED *cpy_info)
{
- H5T_t *dt_dst = (H5T_t *)mesg_dst; /* Destination datatype */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5T_t *dt_dst = (H5T_t *)mesg_dst; /* Destination datatype */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
- if(dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) {
+ if (dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) {
HDassert(H5T_is_named(dt_dst));
- if(H5O_loc_reset(&(dt_dst->oloc)) < 0)
+ if (H5O_loc_reset(&(dt_dst->oloc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to reset location")
dt_dst->oloc.file = dt_dst->sh_loc.file;
dt_dst->oloc.addr = dt_dst->sh_loc.u.loc.oh_addr;
@@ -1648,7 +1644,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__dtype_shared_post_copy_upd */
-
/*--------------------------------------------------------------------------
NAME
H5O__dtype_debug
@@ -1656,27 +1651,26 @@ done:
Prints debugging information for a message
USAGE
void *H5O__dtype_debug(f, mesg, stream, indent, fwidth)
- H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source simple datatype
- struct
- FILE *stream; IN: Pointer to the stream for output data
- int indent; IN: Amount to indent information by
- int fwidth; IN: Field width (?)
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ const void *mesg; IN: Pointer to the source simple datatype
+ struct
+ FILE *stream; IN: Pointer to the stream for output data
+ int indent; IN: Amount to indent information by
+ int fwidth; IN: Field width (?)
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
- This function prints debugging output to the stream passed as a
+ This function prints debugging output to the stream passed as a
parameter.
--------------------------------------------------------------------------*/
static herr_t
-H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
- int fwidth)
+H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidth)
{
- const H5T_t *dt = (const H5T_t*)mesg;
- const char *s;
- char buf[256];
- unsigned i;
- size_t k;
+ const H5T_t *dt = (const H5T_t *)mesg;
+ const char * s;
+ char buf[256];
+ unsigned i;
+ size_t k;
FUNC_ENTER_STATIC_NOERR
@@ -1739,61 +1733,48 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = buf;
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Type class:",
- s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type class:", s);
- HDfprintf(stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth,
- "Size:",
- (unsigned long)(dt->shared->size), 1 == dt->shared->size ? "" : "s");
+ HDfprintf(stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth, "Size:", (unsigned long)(dt->shared->size),
+ 1 == dt->shared->size ? "" : "s");
- HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Version:", dt->shared->version);
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Version:", dt->shared->version);
if (H5T_COMPOUND == dt->shared->type) {
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Number of members:",
- dt->shared->u.compnd.nmembs);
- for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
+ "Number of members:", dt->shared->u.compnd.nmembs);
+ for (i = 0; i < dt->shared->u.compnd.nmembs; i++) {
HDsprintf(buf, "Member %u:", i);
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- buf,
- dt->shared->u.compnd.memb[i].name);
- HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0, fwidth-3),
- "Byte offset:",
- (unsigned long)(dt->shared->u.compnd.memb[i].offset));
- H5O__dtype_debug(f, dt->shared->u.compnd.memb[i].type, stream,
- indent + 3, MAX(0, fwidth - 3));
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.compnd.memb[i].name);
+ HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3),
+ "Byte offset:", (unsigned long)(dt->shared->u.compnd.memb[i].offset));
+ H5O__dtype_debug(f, dt->shared->u.compnd.memb[i].type, stream, indent + 3, MAX(0, fwidth - 3));
} /* end for */
- } /* end if */
- else if(H5T_ENUM == dt->shared->type) {
+ } /* end if */
+ else if (H5T_ENUM == dt->shared->type) {
HDfprintf(stream, "%*s%s\n", indent, "", "Base type:");
- H5O__dtype_debug(f, dt->shared->parent, stream, indent+3, MAX(0, fwidth-3));
+ H5O__dtype_debug(f, dt->shared->parent, stream, indent + 3, MAX(0, fwidth - 3));
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Number of members:",
- dt->shared->u.enumer.nmembs);
- for(i = 0; i < dt->shared->u.enumer.nmembs; i++) {
+ "Number of members:", dt->shared->u.enumer.nmembs);
+ for (i = 0; i < dt->shared->u.enumer.nmembs; i++) {
HDsprintf(buf, "Member %u:", i);
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- buf,
- dt->shared->u.enumer.name[i]);
- HDfprintf(stream, "%*s%-*s 0x", indent, "", fwidth,
- "Raw bytes of value:");
- for(k = 0; k < dt->shared->parent->shared->size; k++)
- HDfprintf(stream, "%02x", (unsigned)*((uint8_t *)dt->shared->u.enumer.value + (i * dt->shared->parent->shared->size) + k));
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.enumer.name[i]);
+ HDfprintf(stream, "%*s%-*s 0x", indent, "", fwidth, "Raw bytes of value:");
+ for (k = 0; k < dt->shared->parent->shared->size; k++)
+ HDfprintf(stream, "%02x",
+ (unsigned)*((uint8_t *)dt->shared->u.enumer.value +
+ (i * dt->shared->parent->shared->size) + k));
HDfprintf(stream, "\n");
} /* end for */
+ } /* end else if */
+ else if (H5T_OPAQUE == dt->shared->type) {
+ HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, "Tag:", dt->shared->u.opaque.tag);
} /* end else if */
- else if(H5T_OPAQUE == dt->shared->type) {
- HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth,
- "Tag:", dt->shared->u.opaque.tag);
- } /* end else if */
- else if(H5T_REFERENCE == dt->shared->type) {
- HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth,
- "Fix dumping reference types!");
+ else if (H5T_REFERENCE == dt->shared->type) {
+ HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Fix dumping reference types!");
} /* end else if */
- else if(H5T_STRING == dt->shared->type) {
- switch(dt->shared->u.atomic.u.s.cset) {
+ else if (H5T_STRING == dt->shared->type) {
+ switch (dt->shared->u.atomic.u.s.cset) {
case H5T_CSET_ASCII:
s = "ASCII";
break;
@@ -1826,11 +1807,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = buf;
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Character Set:",
- s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Character Set:", s);
- switch(dt->shared->u.atomic.u.s.pad) {
+ switch (dt->shared->u.atomic.u.s.pad) {
case H5T_STR_NULLTERM:
s = "NULL Terminated";
break;
@@ -1866,12 +1845,10 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = buf;
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "String Padding:",
- s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "String Padding:", s);
} /* end else if */
- else if(H5T_VLEN == dt->shared->type) {
- switch(dt->shared->u.vlen.type) {
+ else if (H5T_VLEN == dt->shared->type) {
+ switch (dt->shared->u.vlen.type) {
case H5T_VLEN_SEQUENCE:
s = "sequence";
break;
@@ -1887,10 +1864,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = buf;
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Vlen type:", s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Vlen type:", s);
- switch(dt->shared->u.vlen.loc) {
+ switch (dt->shared->u.vlen.loc) {
case H5T_LOC_MEMORY:
s = "memory";
break;
@@ -1906,12 +1882,11 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = buf;
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Location:", s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Location:", s);
/* Extra information for VL-strings */
- if(dt->shared->u.vlen.type == H5T_VLEN_STRING) {
- switch(dt->shared->u.vlen.cset) {
+ if (dt->shared->u.vlen.type == H5T_VLEN_STRING) {
+ switch (dt->shared->u.vlen.cset) {
case H5T_CSET_ASCII:
s = "ASCII";
break;
@@ -1944,11 +1919,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = buf;
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Character Set:",
- s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Character Set:", s);
- switch(dt->shared->u.vlen.pad) {
+ switch (dt->shared->u.vlen.pad) {
case H5T_STR_NULLTERM:
s = "NULL Terminated";
break;
@@ -1984,17 +1957,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = buf;
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "String Padding:",
- s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "String Padding:", s);
} /* end if */
- } /* end else if */
- else if(H5T_ARRAY == dt->shared->type) {
- HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Rank:",
- dt->shared->u.array.ndims);
+ } /* end else if */
+ else if (H5T_ARRAY == dt->shared->type) {
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Rank:", dt->shared->u.array.ndims);
HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:");
- for(i = 0; i < dt->shared->u.array.ndims; i++)
+ for (i = 0; i < dt->shared->u.array.ndims; i++)
HDfprintf(stream, "%s%u", (i ? ", " : ""), (unsigned)dt->shared->u.array.dim[i]);
HDfprintf(stream, "}\n");
HDfprintf(stream, "%*s%s\n", indent, "", "Base type:");
@@ -2028,19 +1997,15 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = buf;
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Byte order:",
- s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Byte order:", s);
HDfprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth,
- "Precision:",
- (unsigned long)(dt->shared->u.atomic.prec),
- 1==dt->shared->u.atomic.prec?"":"s");
+ "Precision:", (unsigned long)(dt->shared->u.atomic.prec),
+ 1 == dt->shared->u.atomic.prec ? "" : "s");
HDfprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth,
- "Offset:",
- (unsigned long)(dt->shared->u.atomic.offset),
- 1==dt->shared->u.atomic.offset?"":"s");
+ "Offset:", (unsigned long)(dt->shared->u.atomic.offset),
+ 1 == dt->shared->u.atomic.offset ? "" : "s");
switch (dt->shared->u.atomic.lsb_pad) {
case H5T_PAD_ZERO:
@@ -2061,8 +2026,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = "pad?";
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Low pad type:", s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Low pad type:", s);
switch (dt->shared->u.atomic.msb_pad) {
case H5T_PAD_ZERO:
@@ -2083,8 +2047,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = "pad?";
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "High pad type:", s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "High pad type:", s);
if (H5T_FLOAT == dt->shared->type) {
switch (dt->shared->u.atomic.u.f.pad) {
@@ -2110,8 +2073,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
s = buf;
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Internal pad type:", s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Internal pad type:", s);
switch (dt->shared->u.atomic.u.f.norm) {
case H5T_NORM_IMPLIED:
@@ -2128,35 +2090,28 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
case H5T_NORM_ERROR:
default:
- HDsprintf(buf, "H5T_NORM_%d", (int) (dt->shared->u.atomic.u.f.norm));
+ HDsprintf(buf, "H5T_NORM_%d", (int)(dt->shared->u.atomic.u.f.norm));
s = buf;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Normalization:", s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Normalization:", s);
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Sign bit location:",
- (unsigned long) (dt->shared->u.atomic.u.f.sign));
+ "Sign bit location:", (unsigned long)(dt->shared->u.atomic.u.f.sign));
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Exponent location:",
- (unsigned long) (dt->shared->u.atomic.u.f.epos));
+ "Exponent location:", (unsigned long)(dt->shared->u.atomic.u.f.epos));
HDfprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth,
- "Exponent bias:",
- (unsigned long) (dt->shared->u.atomic.u.f.ebias));
+ "Exponent bias:", (unsigned long)(dt->shared->u.atomic.u.f.ebias));
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Exponent size:",
- (unsigned long) (dt->shared->u.atomic.u.f.esize));
+ "Exponent size:", (unsigned long)(dt->shared->u.atomic.u.f.esize));
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Mantissa location:",
- (unsigned long) (dt->shared->u.atomic.u.f.mpos));
+ "Mantissa location:", (unsigned long)(dt->shared->u.atomic.u.f.mpos));
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Mantissa size:",
- (unsigned long) (dt->shared->u.atomic.u.f.msize));
+ "Mantissa size:", (unsigned long)(dt->shared->u.atomic.u.f.msize));
} /* end if */
else if (H5T_INTEGER == dt->shared->type) {
@@ -2172,15 +2127,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent,
case H5T_SGN_ERROR:
case H5T_NSGN:
default:
- HDsprintf(buf, "H5T_SGN_%d", (int) (dt->shared->u.atomic.u.i.sign));
+ HDsprintf(buf, "H5T_SGN_%d", (int)(dt->shared->u.atomic.u.i.sign));
s = buf;
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Sign scheme:", s);
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Sign scheme:", s);
} /* end else if */
- } /* end else */
+ } /* end else */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O__dtype_debug() */
-