summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5Odtype.c139
-rw-r--r--src/H5Osdspace.c251
-rw-r--r--src/H5T.c15
-rw-r--r--src/H5Tarray.c172
-rw-r--r--src/H5Tconv.c69
-rw-r--r--src/H5Tnative.c38
-rw-r--r--src/H5Tpkg.h9
-rw-r--r--src/H5Tpublic.h5
8 files changed, 340 insertions, 358 deletions
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 645f547..0a8671b 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -111,7 +111,7 @@ static herr_t
H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
{
unsigned flags, version;
- unsigned i, j;
+ unsigned i;
size_t z;
herr_t ret_value = SUCCEED; /* Return value */
@@ -215,6 +215,7 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
case H5T_COMPOUND:
{
unsigned offset_nbytes; /* Size needed to encode member offsets */
+ unsigned j;
/* Compute the # of bytes required to store a member offset */
offset_nbytes = (H5V_log2_gen((hsize_t)dt->shared->size) + 7) / 8;
@@ -232,8 +233,6 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
unsigned ndims = 0; /* Number of dimensions of the array field */
hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */
- int perm[H5O_LAYOUT_NDIMS]; /* Dimension permutations */
- unsigned perm_word = 0; /* Dimension permutation information */
H5T_t *array_dt; /* Temporary pointer to the array datatype */
H5T_t *temp_type; /* Temporary pointer to the field's datatype */
@@ -264,8 +263,8 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
HDassert(ndims <= 4);
*pp += 3; /*reserved bytes */
- /* Decode dimension permutation (unused currently) */
- UINT32DECODE(*pp, perm_word);
+ /* Skip dimension permutation */
+ *pp += 4;
/* Skip reserved bytes */
*pp += 4;
@@ -291,12 +290,8 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
if(version == H5O_DTYPE_VERSION_1) {
/* Check if this member is an array field */
if(ndims > 0) {
- /* Set up the permutation vector for the array create */
- for(j = 0; j < ndims; j++)
- perm[j]=(perm_word >> (j * 8)) & 0xff;
-
/* Create the array datatype for the field */
- if((array_dt = H5T_array_create(temp_type, (int)ndims, dim, perm)) == NULL) {
+ 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);
@@ -441,25 +436,26 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
UINT16DECODE(*pp, dt->shared->u.atomic.prec);
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 */
- assert(dt->shared->u.array.ndims <= H5S_MAX_RANK);
+ HDassert(dt->shared->u.array.ndims <= H5S_MAX_RANK);
- /* Skip reserved bytes */
- *pp += 3;
+ /* Skip reserved bytes, if version has them */
+ if(version < H5O_DTYPE_VERSION_3)
+ *pp += 3;
/* Decode array dimension sizes & compute number of elements */
- for(j = 0, dt->shared->u.array.nelem = 1; j < (unsigned)dt->shared->u.array.ndims; j++) {
- UINT32DECODE(*pp, dt->shared->u.array.dim[j]);
- dt->shared->u.array.nelem *= dt->shared->u.array.dim[j];
+ 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 */
- /* Decode array dimension permutations (even though they are unused currently) */
- for(j = 0; j < (unsigned)dt->shared->u.array.ndims; j++)
- UINT32DECODE(*pp, dt->shared->u.array.perm[j]);
+ /* Skip array dimension permutations, if version has them */
+ 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()))
@@ -856,25 +852,31 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
UINT16ENCODE(*pp, dt->shared->u.atomic.prec);
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);
/* Encode the number of dimensions */
*(*pp)++ = dt->shared->u.array.ndims;
- /* Reserved */
- *(*pp)++ = '\0';
- *(*pp)++ = '\0';
- *(*pp)++ = '\0';
+ /* Drop this information for Version 3 of the format */
+ if(!use_latest_format) {
+ /* Reserved */
+ *(*pp)++ = '\0';
+ *(*pp)++ = '\0';
+ *(*pp)++ = '\0';
+ } /* end if */
/* Encode array dimensions */
for(i = 0; i < (unsigned)dt->shared->u.array.ndims; i++)
UINT32ENCODE(*pp, dt->shared->u.array.dim[i]);
- /* Encode array dimension permutations */
- for(i = 0; i < (unsigned)dt->shared->u.array.ndims; i++)
- UINT32ENCODE(*pp, dt->shared->u.array.perm[i]);
+ /* Drop this information for Version 3 of the format */
+ if(!use_latest_format) {
+ /* Encode 'fake' array dimension permutations */
+ 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(f, pp, dt->shared->parent) < 0)
@@ -890,8 +892,9 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
/* (unless the "use the latest format" flag is set, which can "upgrade" the
* format of certain encodings)
*/
- if(has_vax ||
- (use_latest_format && (dt->shared->type == H5T_ENUM || dt->shared->type == H5T_COMPOUND)))
+ if(use_latest_format)
+ version = H5O_DTYPE_VERSION_LATEST;
+ else if(has_vax)
version = H5O_DTYPE_VERSION_3;
else if(has_array)
version = H5O_DTYPE_VERSION_2;
@@ -1069,15 +1072,19 @@ done:
static size_t
H5O_dtype_size(const H5F_t *f, const void *_mesg)
{
- const H5T_t *dt = (const H5T_t *)_mesg;
- unsigned i; /* Local index variable */
- size_t ret_value;
+ const H5T_t *dt = (const H5T_t *)_mesg;
+ hbool_t use_latest_format; /* Flag indicating the new group format should be used */
+ unsigned u; /* Local index variable */
+ size_t ret_value;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_size)
HDassert(f);
HDassert(dt);
+ /* Get the file's 'use the latest version of the format' flag */
+ use_latest_format = H5F_USE_LATEST_FORMAT(f);
+
/* Set the common size information */
ret_value = 4 + /* Type, class & flags */
4; /* Size of datatype */
@@ -1103,25 +1110,21 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg)
case H5T_COMPOUND:
{
htri_t has_array; /* Whether a compound datatype has an array inside it */
- hbool_t use_latest_format; /* Flag indicating the new group format should be used */
unsigned offset_nbytes; /* Size needed to encode member offsets */
/* Check for an array datatype somewhere within the compound type */
has_array = H5T_detect_class(dt, H5T_ARRAY);
HDassert(has_array >= 0);
- /* Get the file's 'use the latest version of the format' flag */
- use_latest_format = H5F_USE_LATEST_FORMAT(f);
-
/* Compute the # of bytes required to store a member offset */
offset_nbytes = (H5V_log2_gen((hsize_t)dt->shared->size) + 7) / 8;
/* Compute the total size needed to encode compound datatype */
- for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
+ 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[i].name);
+ name_len = HDstrlen(dt->shared->u.compnd.memb[u].name);
/* Newer versions of the format don't pad out the name */
if(use_latest_format)
@@ -1142,33 +1145,26 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg)
4 + /*permutation*/
4 + /*reserved*/
16; /*dimensions*/
- ret_value += H5O_dtype_size(f, dt->shared->u.compnd.memb[i].type);
+ ret_value += H5O_dtype_size(f, dt->shared->u.compnd.memb[u].type);
} /* end for */
}
break;
case H5T_ENUM:
- {
- hbool_t use_latest_format; /* Flag indicating the new group format should be used */
-
- /* Get the file's 'use the latest version of the format' flag */
- use_latest_format = H5F_USE_LATEST_FORMAT(f);
-
- ret_value += H5O_dtype_size(f, dt->shared->parent);
- for(i = 0; i < dt->shared->u.enumer.nmembs; i++) {
- size_t name_len; /* Length of field's name */
+ 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 */
- /* Get length of field's name */
- name_len = HDstrlen(dt->shared->u.enumer.name[i]);
+ /* Get length of field's name */
+ name_len = HDstrlen(dt->shared->u.enumer.name[u]);
- /* Newer versions of the format don't pad out the name */
- if(use_latest_format)
- ret_value += name_len + 1;
- else
- ret_value += ((name_len + 8) / 8) * 8;
- } /* end for */
- ret_value += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size;
- }
+ /* Newer versions of the format don't pad out the name */
+ if(use_latest_format)
+ ret_value += name_len + 1;
+ else
+ ret_value += ((name_len + 8) / 8) * 8;
+ } /* end for */
+ ret_value += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size;
break;
case H5T_VLEN:
@@ -1180,9 +1176,12 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg)
break;
case H5T_ARRAY:
- ret_value += 4; /* ndims & reserved bytes*/
+ ret_value += 1; /* ndims */
+ if(!use_latest_format)
+ ret_value += 3; /* reserved bytes*/
ret_value += 4 * dt->shared->u.array.ndims; /* dimensions */
- ret_value += 4 * dt->shared->u.array.ndims; /* dimension permutations */
+ if(!use_latest_format)
+ ret_value += 4 * dt->shared->u.array.ndims; /* dimension permutations */
ret_value += H5O_dtype_size(f, dt->shared->parent);
break;
@@ -1534,22 +1533,16 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream,
}
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Location:", s);
- } else if (H5T_ARRAY==dt->shared->type) {
+ } else if(H5T_ARRAY == dt->shared->type) {
fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
"Rank:",
dt->shared->u.array.ndims);
- fprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:");
- for (i=0; i<(unsigned)dt->shared->u.array.ndims; i++) {
- fprintf (stream, "%s%u", i?", ":"", (unsigned)dt->shared->u.array.dim[i]);
- }
- fprintf (stream, "}\n");
- fprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Permutation:");
- for (i=0; i<(unsigned)dt->shared->u.array.ndims; i++) {
- fprintf (stream, "%s%d", i?", ":"", dt->shared->u.array.perm[i]);
- }
- fprintf (stream, "}\n");
+ fprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:");
+ for(i = 0; i < dt->shared->u.array.ndims; i++)
+ fprintf(stream, "%s%u", (i ? ", " : ""), (unsigned)dt->shared->u.array.dim[i]);
+ fprintf(stream, "}\n");
fprintf(stream, "%*s%s\n", indent, "", "Base type:");
- H5O_dtype_debug(f, dxpl_id, dt->shared->parent, stream, indent+3, MAX(0, fwidth-3));
+ H5O_dtype_debug(f, dxpl_id, dt->shared->parent, stream, indent + 3, MAX(0, fwidth - 3));
} else {
switch (dt->shared->u.atomic.order) {
case H5T_ORDER_LE:
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index f6be82b..32be4bc 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -55,11 +55,19 @@ const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{
H5O_sdspace_debug /* debug the message */
}};
-/* Initial version of the "old" data space information */
-#define H5O_SDSPACE_VERSION 1
-/* Initial version of the "new" data space information */
+/* Initial version of the dataspace information */
+#define H5O_SDSPACE_VERSION_1 1
+
+/* This version adds support for "null" dataspaces, encodes the type of the
+ * dataspace in the message and eliminated the rest of the "reserved"
+ * bytes.
+ */
#define H5O_SDSPACE_VERSION_2 2
+/* The latest version of the format. Look through the 'encode'
+ * and 'size' callbacks for places to change when updating this. */
+#define H5O_SDSPACE_VERSION_LATEST H5O_SDSPACE_VERSION_2
+
/* Declare external the free list for H5S_extent_t's */
H5FL_EXTERN(H5S_extent_t);
@@ -107,83 +115,87 @@ H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
unsigned i; /* local counting variable */
unsigned flags, version;
- FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_decode);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_decode)
/* check args */
- assert(f);
- assert(p);
+ HDassert(f);
+ HDassert(p);
/* decode */
- if ((sdim = H5FL_CALLOC(H5S_extent_t)) != NULL) {
- /* Check version */
- version = *p++;
- if (version!=H5O_SDSPACE_VERSION && version!=H5O_SDSPACE_VERSION_2)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "wrong version number in data space message");
-
- /* Get rank */
- sdim->rank = *p++;
- if (sdim->rank>H5S_MAX_RANK)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "simple data space dimensionality is too large");
-
- /* Get dataspace flags for later */
- flags = *p++;
-
- /* Get the type of the extent */
- if(version>=H5O_SDSPACE_VERSION_2)
- sdim->type = (H5S_class_t)*p++;
- else {
- /* Set the dataspace type to be simple or scalar as appropriate */
- if(sdim->rank>0)
- sdim->type = H5S_SIMPLE;
- else
- sdim->type = H5S_SCALAR;
-
- /* Increment past reserved byte */
- p++;
- } /* end else */
-
+ if(NULL == (sdim = H5FL_CALLOC(H5S_extent_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, NULL, "dataspace structure allocation failed")
+
+ /* Check version */
+ version = *p++;
+ if(version < H5O_SDSPACE_VERSION_1 || version > H5O_SDSPACE_VERSION_2)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "wrong version number in dataspace message")
+
+ /* Get rank */
+ sdim->rank = *p++;
+ if(sdim->rank > H5S_MAX_RANK)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "simple dataspace dimensionality is too large")
+
+ /* Get dataspace flags for later */
+ flags = *p++;
+
+ /* Get or determine the type of the extent */
+ if(version >= H5O_SDSPACE_VERSION_2)
+ sdim->type = (H5S_class_t)*p++;
+ else {
+ /* Set the dataspace type to be simple or scalar as appropriate */
+ if(sdim->rank > 0)
+ sdim->type = H5S_SIMPLE;
+ else
+ sdim->type = H5S_SCALAR;
+
+ /* Increment past reserved byte */
+ p++;
+ } /* end else */
+
+ /* Only Version 1 has these reserved bytes */
+ if(version == H5O_SDSPACE_VERSION_1)
p += 4; /*reserved*/
- if(sdim->rank > 0) {
- if(NULL == (sdim->size = H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- for(i = 0; i < sdim->rank; i++) {
- H5F_DECODE_LENGTH (f, p, sdim->size[i]);
+ /* Decode dimension sizes */
+ if(sdim->rank > 0) {
+ if(NULL == (sdim->size = H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ for(i = 0; i < sdim->rank; i++) {
+ H5F_DECODE_LENGTH(f, p, sdim->size[i]);
#ifndef H5_HAVE_LARGE_HSIZET
- /* Rudimentary check for overflow of the dimension size */
- if(sdim->size[i] == 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADSIZE, NULL, "invalid size detected");
+ /* Rudimentary check for overflow of the dimension size */
+ if(sdim->size[i] == 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADSIZE, NULL, "invalid size detected")
#endif /* H5_HAVE_LARGE_HSIZET */
- } /* end for */
+ } /* end for */
- if(flags & H5S_VALID_MAX) {
- if(NULL == (sdim->max = H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- for(i = 0; i < sdim->rank; i++)
- H5F_DECODE_LENGTH (f, p, sdim->max[i]);
- }
- }
+ if(flags & H5S_VALID_MAX) {
+ if(NULL == (sdim->max = H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ for(i = 0; i < sdim->rank; i++)
+ H5F_DECODE_LENGTH (f, p, sdim->max[i]);
+ } /* end if */
+ } /* end if */
- /* Compute the number of elements in the extent */
- if(sdim->type == H5S_NULL)
- sdim->nelem = 0;
- else {
- for(i=0, sdim->nelem=1; i<sdim->rank; i++)
- sdim->nelem*=sdim->size[i];
- }
- }
+ /* Compute the number of elements in the extent */
+ if(sdim->type == H5S_NULL)
+ sdim->nelem = 0;
+ else {
+ for(i = 0, sdim->nelem = 1; i < sdim->rank; i++)
+ sdim->nelem *= sdim->size[i];
+ } /* end else */
/* Set return value */
ret_value = (void*)sdim; /*success*/
done:
- if (!ret_value && sdim) {
+ if(!ret_value && sdim) {
H5S_extent_release(sdim);
- H5FL_FREE(H5S_extent_t,sdim);
+ H5FL_FREE(H5S_extent_t, sdim);
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_sdspace_decode() */
/*--------------------------------------------------------------------------
@@ -218,50 +230,64 @@ done:
--------------------------------------------------------------------------*/
static herr_t
-H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *mesg)
+H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg)
{
- const H5S_extent_t *sdim = (const H5S_extent_t *) mesg;
- unsigned u; /* Local counting variable */
+ const H5S_extent_t *sdim = (const H5S_extent_t *)_mesg;
unsigned flags = 0;
+ unsigned version;
+ hbool_t use_latest_format; /* Flag indicating the new group format should be used */
+ unsigned u; /* Local counting variable */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_encode);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_encode)
/* check args */
- assert(f);
- assert(p);
- assert(sdim);
-
- /* set flags */
- if (sdim->max)
- flags |= H5S_VALID_MAX;
-
- /* encode */
- if(sdim->type!=H5S_NULL)
- *p++ = H5O_SDSPACE_VERSION;
+ HDassert(f);
+ HDassert(p);
+ HDassert(sdim);
+
+ /* Get the file's 'use the latest version of the format' flag */
+ use_latest_format = H5F_USE_LATEST_FORMAT(f);
+
+ /* Version */
+ if(use_latest_format)
+ version = H5O_SDSPACE_VERSION_LATEST;
+ else if(sdim->type == H5S_NULL || use_latest_format)
+ version = H5O_SDSPACE_VERSION_2;
else
- *p++ = H5O_SDSPACE_VERSION_2;
+ version = H5O_SDSPACE_VERSION_1;
+ *p++ = version;
+
+ /* Rank */
*p++ = sdim->rank;
+
+ /* Flags */
+ if(sdim->max)
+ flags |= H5S_VALID_MAX;
*p++ = flags;
- if(sdim->type!=H5S_NULL)
- *p++ = 0; /*reserved*/
- else
- *p++ = sdim->type;
- *p++ = 0; /*reserved*/
- *p++ = 0; /*reserved*/
- *p++ = 0; /*reserved*/
- *p++ = 0; /*reserved*/
- if (sdim->rank > 0) {
- for (u = 0; u < sdim->rank; u++)
- H5F_ENCODE_LENGTH (f, p, sdim->size[u]);
- if (flags & H5S_VALID_MAX) {
- for (u = 0; u < sdim->rank; u++)
- H5F_ENCODE_LENGTH (f, p, sdim->max[u]);
- }
- }
+ /* Dataspace type */
+ if(version > H5O_SDSPACE_VERSION_1)
+ *p++ = sdim->type;
+ else {
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ } /* end else */
+
+ /* Current & maximum dimensions */
+ if(sdim->rank > 0) {
+ for(u = 0; u < sdim->rank; u++)
+ H5F_ENCODE_LENGTH(f, p, sdim->size[u]);
+ if(flags & H5S_VALID_MAX) {
+ for(u = 0; u < sdim->rank; u++)
+ H5F_ENCODE_LENGTH(f, p, sdim->max[u]);
+ } /* end if */
+ } /* end if */
- FUNC_LEAVE_NOAPI(SUCCEED);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_sdspace_encode() */
/*--------------------------------------------------------------------------
@@ -332,25 +358,32 @@ done:
instead of just four bytes.
--------------------------------------------------------------------------*/
static size_t
-H5O_sdspace_size(const H5F_t *f, const void *mesg)
+H5O_sdspace_size(const H5F_t *f, const void *_mesg)
{
- const H5S_extent_t *space = (const H5S_extent_t *) mesg;
+ const H5S_extent_t *space = (const H5S_extent_t *)_mesg;
+ hbool_t use_latest_format; /* Flag indicating the new group format should be used */
+ size_t ret_value;
- /*
- * All dimensionality messages are at least 8 bytes long.
- */
- size_t ret_value = 8;
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_size)
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_size);
+ /* Get the file's 'use the latest version of the format' flag */
+ use_latest_format = H5F_USE_LATEST_FORMAT(f);
- /* add in the dimension sizes */
- ret_value += space->rank * H5F_SIZEOF_SIZE (f);
+ /* Basic information for all dataspace messages */
+ ret_value = 1 + /* Version */
+ 1 + /* Rank */
+ 1 + /* Flags */
+ 1 + /* Dataspace type/reserved */
+ (use_latest_format ? 0 : 4); /* Eliminated/reserved */
- /* add in the space for the maximum dimensions, if they are present */
- ret_value += space->max ? space->rank * H5F_SIZEOF_SIZE (f) : 0;
+ /* Add in the dimension sizes */
+ ret_value += space->rank * H5F_SIZEOF_SIZE(f);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ /* Add in the space for the maximum dimensions, if they are present */
+ ret_value += space->max ? (space->rank * H5F_SIZEOF_SIZE(f)) : 0;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_sdspace_size() */
/*-------------------------------------------------------------------------
diff --git a/src/H5T.c b/src/H5T.c
index 7acf1e9..aebeb57 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -1006,7 +1006,7 @@ H5T_init_interface(void)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL == (vlen = H5T_vlen_create(native_int)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
- if (NULL == (array = H5T_array_create(native_int,1,dim,NULL)))
+ if (NULL == (array = H5T_array_create(native_int, 1, dim)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
status = 0;
@@ -4047,17 +4047,10 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
if (dt1->shared->u.array.ndims > dt2->shared->u.array.ndims)
HGOTO_DONE(1);
- for (j=0; j<dt1->shared->u.array.ndims; j++) {
- if (dt1->shared->u.array.dim[j] < dt2->shared->u.array.dim[j])
+ for (u=0; u<dt1->shared->u.array.ndims; u++) {
+ if (dt1->shared->u.array.dim[u] < dt2->shared->u.array.dim[u])
HGOTO_DONE(-1);
- if (dt1->shared->u.array.dim[j] > dt2->shared->u.array.dim[j])
- HGOTO_DONE(1);
- }
-
- for (j=0; j<dt1->shared->u.array.ndims; j++) {
- if (dt1->shared->u.array.perm[j] < dt2->shared->u.array.perm[j])
- HGOTO_DONE(-1);
- if (dt1->shared->u.array.perm[j] > dt2->shared->u.array.perm[j])
+ if (dt1->shared->u.array.dim[u] > dt2->shared->u.array.dim[u])
HGOTO_DONE(1);
}
diff --git a/src/H5Tarray.c b/src/H5Tarray.c
index 71c80b8..3fdf3a5 100644
--- a/src/H5Tarray.c
+++ b/src/H5Tarray.c
@@ -57,57 +57,54 @@ H5T_init_array_interface(void)
* Purpose: Create a new array data type based on the specified BASE_TYPE.
* The type is an array with NDIMS dimensionality and the size of the
* array is DIMS. The total member size should be relatively small.
- * PERM is currently unimplemented and unused, but is designed to contain
- * the dimension permutation from C order.
* Array datatypes are currently limited to H5S_MAX_RANK number of
* dimensions and must have the number of dimensions set greater than
* 0. (i.e. 0 > ndims <= H5S_MAX_RANK) All dimensions sizes must be greater
* than 0 also.
*
* Return: Success: ID of new array data type
- *
* Failure: Negative
*
* Programmer: Quincey Koziol
* Thursday, Oct 26, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hid_t
-H5Tarray_create(hid_t base_id, int ndims, const hsize_t dim[/* ndims */],
- const int perm[/* ndims */])
+H5Tarray_create(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */],
+ const int UNUSED perm[/* ndims */])
{
- H5T_t *base = NULL; /* base data type */
- H5T_t *dt = NULL; /* new array data type */
- int i; /* local index variable */
- hid_t ret_value; /* return value */
+ H5T_t *base; /* base data type */
+ H5T_t *dt; /* new array data type */
+ unsigned u; /* local index variable */
+ hid_t ret_value; /* return value */
- FUNC_ENTER_API(H5Tarray_create, FAIL);
- H5TRACE4("i","iIs*h*Is",base_id,ndims,dim,perm);
+ FUNC_ENTER_API(H5Tarray_create, FAIL)
+ H5TRACE3("i","iIs*h",base_id,ndims,dim);
/* Check args */
- if (ndims<1 || ndims>H5S_MAX_RANK)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimensionality");
- if (ndims>0 && !dim)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
- for(i=0; i<ndims; i++)
- if(!(dim[i]>0))
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero-sized dimension specified");
- if (NULL==(base=H5I_object_verify(base_id,H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype");
+ if(ndims < 1 || ndims > H5S_MAX_RANK)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimensionality")
+ if(!dim)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified")
+ for(u = 0; u < ndims; u++)
+ if(!(dim[u] > 0))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero-sized dimension specified")
+ if(NULL == (base = H5I_object_verify(base_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype")
+ if(perm)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimension permutations not supported")
/* Create the actual array datatype */
- if ((dt=H5T_array_create(base,ndims,dim,perm))==NULL)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create datatype");
+ if((dt = H5T_array_create(base, ndims, dim)) == NULL)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create datatype")
/* Atomize the type */
- if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype");
+ if((ret_value = H5I_register(H5I_DATATYPE, dt)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype")
done:
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
} /* end H5Tarray_create */
@@ -116,34 +113,29 @@ done:
*
* Purpose: Internal routine to create a new array data type based on the
* specified BASE_TYPE. The type is an array with NDIMS dimensionality
- * and the size of the array is DIMS. PERM is currently unimplemented
- * and unused, but is designed to contain the dimension permutation from
- * C order. Array datatypes are currently limited to H5S_MAX_RANK number
- * of * dimensions.
+ * and the size of the array is DIMS.
+ * Array datatypes are currently limited to H5S_MAX_RANK number
+ * of dimensions.
*
* Return: Success: ID of new array data type
- *
* Failure: Negative
*
* Programmer: Quincey Koziol
* Thursday, Oct 26, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
H5T_t *
-H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */],
- const int perm[/* ndims */])
+H5T_array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */])
{
- H5T_t *ret_value = NULL; /*new array data type */
- int i; /* local index variable */
+ H5T_t *ret_value; /* new array data type */
+ unsigned u; /* local index variable */
- FUNC_ENTER_NOAPI(H5T_array_create, NULL);
+ FUNC_ENTER_NOAPI(H5T_array_create, NULL)
- assert(base);
- assert(ndims>0 && ndims<=H5S_MAX_RANK);
- assert(dim);
+ HDassert(base);
+ HDassert(ndims <= H5S_MAX_RANK);
+ HDassert(dim);
/* Build new type */
if(NULL == (ret_value = H5T_alloc()))
@@ -157,26 +149,22 @@ H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */],
ret_value->shared->u.array.ndims = ndims;
/* Copy the array dimensions & compute the # of elements in the array */
- for(i=0, ret_value->shared->u.array.nelem=1; i<ndims; i++) {
- H5_ASSIGN_OVERFLOW(ret_value->shared->u.array.dim[i],dim[i],hsize_t,size_t);
- ret_value->shared->u.array.nelem *= (size_t)dim[i];
+ for(u = 0, ret_value->shared->u.array.nelem = 1; u < ndims; u++) {
+ H5_ASSIGN_OVERFLOW(ret_value->shared->u.array.dim[u], dim[u], hsize_t, size_t);
+ ret_value->shared->u.array.nelem *= (size_t)dim[u];
} /* end for */
- /* Copy the dimension permutations */
- for(i=0; i<ndims; i++)
- ret_value->shared->u.array.perm[i] = perm ? perm[i] : i;
-
/* Set the array's size (number of elements * element datatype's size) */
ret_value->shared->size = ret_value->shared->parent->shared->size * ret_value->shared->u.array.nelem;
/*
* Set the "force conversion" flag if the base datatype indicates
*/
- if(base->shared->force_conv==TRUE)
- ret_value->shared->force_conv=TRUE;
+ if(base->shared->force_conv == TRUE)
+ ret_value->shared->force_conv = TRUE;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_array_create */
@@ -191,30 +179,28 @@ done:
* Programmer: Quincey Koziol
* Monday, November 6, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
H5Tget_array_ndims(hid_t type_id)
{
- H5T_t *dt = NULL; /* pointer to array data type */
+ H5T_t *dt; /* pointer to array data type */
int ret_value; /* return value */
- FUNC_ENTER_API(H5Tget_array_ndims, FAIL);
+ FUNC_ENTER_API(H5Tget_array_ndims, FAIL)
H5TRACE1("Is","i",type_id);
/* Check args */
- if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
- if(dt->shared->type!=H5T_ARRAY)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype");
+ if(NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object")
+ if(dt->shared->type != H5T_ARRAY)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype")
/* Retrieve the number of dimensions */
ret_value = H5T_get_array_ndims(dt);
done:
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
} /* end H5Tget_array_ndims */
@@ -230,25 +216,18 @@ done:
* Programmer: Raymond Lu
* October 10, 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
H5T_get_array_ndims(H5T_t *dt)
{
- int ret_value; /* return value */
-
- FUNC_ENTER_NOAPI(H5T_get_array_ndims, FAIL);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_get_array_ndims)
- assert(dt);
- assert(dt->shared->type==H5T_ARRAY);
+ HDassert(dt);
+ HDassert(dt->shared->type == H5T_ARRAY);
/* Retrieve the number of dimensions */
- ret_value=dt->shared->u.array.ndims;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(dt->shared->u.array.ndims)
} /* end H5T_get_array_ndims */
@@ -263,30 +242,28 @@ done:
* Programmer: Quincey Koziol
* Monday, November 6, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
-H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[])
+H5Tget_array_dims(hid_t type_id, hsize_t dims[], int UNUSED perm[])
{
- H5T_t *dt = NULL; /* pointer to array data type */
+ H5T_t *dt; /* pointer to array data type */
int ret_value; /* return value */
- FUNC_ENTER_API(H5Tget_array_dims, FAIL);
- H5TRACE3("Is","i*h*Is",type_id,dims,perm);
+ FUNC_ENTER_API(H5Tget_array_dims, FAIL)
+ H5TRACE2("Is","i*h",type_id,dims);
/* Check args */
- if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
- if(dt->shared->type!=H5T_ARRAY)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype");
+ if(NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object")
+ if(dt->shared->type != H5T_ARRAY)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype")
/* Retrieve the sizes of the dimensions */
- if((ret_value=H5T_get_array_dims(dt, dims, perm))<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get dimension sizes");
+ if((ret_value = H5T_get_array_dims(dt, dims)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get dimension sizes")
done:
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
} /* end H5Tget_array_dims */
@@ -302,35 +279,28 @@ done:
* Programmer: Raymond Lu
* October 10, 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
-H5T_get_array_dims(H5T_t *dt, hsize_t dims[], int perm[])
+H5T_get_array_dims(H5T_t *dt, hsize_t dims[])
{
+ unsigned u; /* Local index variable */
int ret_value; /* return value */
- int i; /* Local index variable */
- FUNC_ENTER_NOAPI(H5T_get_array_dims, FAIL);
+ FUNC_ENTER_NOAPI(H5T_get_array_dims, FAIL)
- assert(dt);
- assert(dt->shared->type==H5T_ARRAY);
+ HDassert(dt);
+ HDassert(dt->shared->type == H5T_ARRAY);
/* Retrieve the sizes of the dimensions */
if(dims)
- for(i=0; i<dt->shared->u.array.ndims; i++)
- dims[i]=dt->shared->u.array.dim[i];
-
- /* Retrieve the dimension permutations */
- if(perm)
- for(i=0; i<dt->shared->u.array.ndims; i++)
- perm[i]=dt->shared->u.array.perm[i];
+ for(u = 0; u < dt->shared->u.array.ndims; u++)
+ dims[u] = dt->shared->u.array.dim[u];
/* Pass along the array rank as the return value */
- ret_value=dt->shared->u.array.ndims;
+ ret_value = dt->shared->u.array.ndims;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_get_array_dims */
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 575dda7..a40287a 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2980,12 +2980,12 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
size_t src_delta, dst_delta; /*source & destination stride */
int direction; /*direction of traversal */
size_t elmtno; /*element number counter */
- int i; /* local index variable */
+ unsigned u; /* local index variable */
void *bkg_buf=NULL; /*temporary background buffer */
size_t bkg_buf_size=0; /*size of background buffer in bytes */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5T_conv_array, FAIL);
+ FUNC_ENTER_NOAPI(H5T_conv_array, FAIL)
switch (cdata->command) {
case H5T_CONV_INIT:
@@ -2996,23 +2996,17 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
* information that remains (almost) constant for this
* conversion path.
*/
- if (NULL == (src = H5I_object(src_id)) ||
- NULL == (dst = H5I_object(dst_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- assert (H5T_ARRAY==src->shared->type);
- assert (H5T_ARRAY==dst->shared->type);
+ if(NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
+ HDassert(H5T_ARRAY==src->shared->type);
+ HDassert(H5T_ARRAY==dst->shared->type);
/* Check the number and sizes of the dimensions */
- if(src->shared->u.array.ndims!=dst->shared->u.array.ndims)
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same number of dimensions");
- for(i=0; i<src->shared->u.array.ndims; i++)
- if(src->shared->u.array.dim[i]!=dst->shared->u.array.dim[i])
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same sizes of dimensions");
-#ifdef LATER
- for(i=0; i<src->shared->u.array.ndims; i++)
- if(src->shared->u.array.perm[i]!=dst->shared->u.array.perm[i])
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same dimension permutations");
-#endif /* LATER */
+ if(src->shared->u.array.ndims != dst->shared->u.array.ndims)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same number of dimensions")
+ for(u = 0; u < src->shared->u.array.ndims; u++)
+ if(src->shared->u.array.dim[u] != dst->shared->u.array.dim[u])
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same sizes of dimensions")
/* Array datatypes don't need a background buffer */
cdata->need_bkg = H5T_BKG_NO;
@@ -3027,22 +3021,21 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
/*
* Conversion.
*/
- if (NULL == (src = H5I_object(src_id)) ||
- NULL == (dst = H5I_object(dst_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
/*
* Do we process the values from beginning to end or vice
* versa? Also, how many of the elements have the source and
* destination areas overlapping?
*/
- if (src->shared->size>=dst->shared->size || buf_stride>0) {
+ if(src->shared->size >= dst->shared->size || buf_stride > 0) {
sp = dp = (uint8_t*)_buf;
direction = 1;
} else {
- sp = (uint8_t*)_buf + (nelmts-1) *
+ sp = (uint8_t*)_buf + (nelmts - 1) *
(buf_stride ? buf_stride : src->shared->size);
- dp = (uint8_t*)_buf + (nelmts-1) *
+ dp = (uint8_t*)_buf + (nelmts - 1) *
(buf_stride ? buf_stride : dst->shared->size);
direction = -1;
}
@@ -3054,24 +3047,24 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
dst_delta = direction * (buf_stride ? buf_stride : dst->shared->size);
/* Set up conversion path for base elements */
- if (NULL==(tpath=H5T_path_find(src->shared->parent, dst->shared->parent, NULL, NULL, dxpl_id, FALSE))) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes");
+ if(NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent, NULL, NULL, dxpl_id, FALSE))) {
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes")
} else if (!H5T_path_noop(tpath)) {
- if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL)))<0 ||
- (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL)))<0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion");
+ if((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL))) < 0 ||
+ (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL))) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion")
}
/* Check if we need a background buffer for this conversion */
if(tpath->cdata.need_bkg) {
/* Allocate background buffer */
- bkg_buf_size=src->shared->u.array.nelem*MAX(src->shared->size,dst->shared->size);
- if ((bkg_buf=H5FL_BLK_CALLOC(array_seq,bkg_buf_size))==NULL)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
+ bkg_buf_size = src->shared->u.array.nelem * MAX(src->shared->size, dst->shared->size);
+ if((bkg_buf = H5FL_BLK_CALLOC(array_seq, bkg_buf_size)) == NULL)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion")
} /* end if */
/* Perform the actual conversion */
- for (elmtno=0; elmtno<nelmts; elmtno++) {
+ for(elmtno = 0; elmtno < nelmts; elmtno++) {
/* Copy the source array into the correct location for the destination */
HDmemmove(dp, sp, src->shared->size);
@@ -3082,16 +3075,16 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
/* Advance the source & destination pointers */
sp += src_delta;
dp += dst_delta;
- }
+ } /* end for */
/* Release the background buffer, if we have one */
- if(bkg_buf!=NULL)
- H5FL_BLK_FREE(array_seq,bkg_buf);
+ if(bkg_buf != NULL)
+ H5FL_BLK_FREE(array_seq, bkg_buf);
/* Release the temporary datatype IDs used */
- if (tsrc_id >= 0)
+ if(tsrc_id >= 0)
H5I_dec_ref(tsrc_id);
- if (tdst_id >= 0)
+ if(tdst_id >= 0)
H5I_dec_ref(tdst_id);
break;
@@ -3100,7 +3093,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
} /* end switch */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_conv_array() */
diff --git a/src/H5Tnative.c b/src/H5Tnative.c
index 56694c2..fb525dc 100644
--- a/src/H5Tnative.c
+++ b/src/H5Tnative.c
@@ -167,10 +167,10 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
assert(dtype);
- if((h5_class = H5T_get_class(dtype, FALSE))==H5T_NO_CLASS)
+ if((h5_class = H5T_get_class(dtype, FALSE)) == H5T_NO_CLASS)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid class")
- if((size = H5T_get_size(dtype))==0)
+ if((size = H5T_get_size(dtype)) == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid size")
switch(h5_class) {
@@ -336,9 +336,9 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
/* Don't need to do anything special for alignment, offset since the ENUM type usually is integer. */
- /* Retrieve base type for enumarate type */
+ /* Retrieve base type for enumerated type */
if((super_type=H5T_get_super(dtype))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get base type for enumarate type")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get base type for enumerate type")
if((nat_super_type = H5T_get_native_type(super_type, direction, struct_align, offset, comp_size))==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "base native type retrieval failed")
@@ -359,7 +359,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
/* Retrieve member info and insert members into new enum type */
if((snmemb = H5T_get_nmembers(dtype))<=0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "enumarate data type doesn't have any member")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "enumerate data type doesn't have any member")
H5_ASSIGN_OVERFLOW(nmemb,snmemb,int,unsigned);
for(i=0; i<nmemb; i++) {
if((memb_name=H5T_get_member_name(dtype, i))==NULL)
@@ -400,37 +400,37 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
size_t super_align=0;
/* Retrieve dimension information for array data type */
- if((sarray_rank=H5T_get_array_ndims(dtype))<=0)
+ if((sarray_rank = H5T_get_array_ndims(dtype)) <= 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension rank")
- H5_ASSIGN_OVERFLOW(array_rank,sarray_rank,int,unsigned);
- if((dims = (hsize_t*)H5MM_malloc(array_rank*sizeof(hsize_t)))==NULL)
+ H5_ASSIGN_OVERFLOW(array_rank, sarray_rank, int, unsigned);
+ if((dims = (hsize_t*)H5MM_malloc(array_rank * sizeof(hsize_t))) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory")
- if(H5T_get_array_dims(dtype, dims, NULL)<0)
+ if(H5T_get_array_dims(dtype, dims) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension size")
/* Retrieve base type for array type */
- if((super_type=H5T_get_super(dtype))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for enumarate type")
+ if((super_type = H5T_get_super(dtype)) == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for array type")
if((nat_super_type = H5T_get_native_type(super_type, direction, &super_align,
- &super_offset, &super_size))==NULL)
+ &super_offset, &super_size)) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed")
/* Close super type */
- if(H5T_close(super_type)<0)
+ if(H5T_close(super_type) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype")
/* Create a new array type based on native type */
- if((new_type=H5T_array_create(nat_super_type, sarray_rank, dims, NULL))==NULL)
+ if((new_type = H5T_array_create(nat_super_type, array_rank, dims)) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create array type")
/* Close base type */
- if(H5T_close(nat_super_type)<0)
+ if(H5T_close(nat_super_type) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype")
- for(i=0; i<array_rank; i++)
+ for(i = 0; i < array_rank; i++)
nelems *= dims[i];
- H5_CHECK_OVERFLOW(nelems,hsize_t,size_t);
- if(H5T_cmp_offset(comp_size, offset, super_size, (size_t)nelems, super_align, struct_align)<0)
+ H5_CHECK_OVERFLOW(nelems, hsize_t, size_t);
+ if(H5T_cmp_offset(comp_size, offset, super_size, (size_t)nelems, super_align, struct_align) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
H5MM_xfree(dims);
@@ -446,7 +446,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
/* Retrieve base type for array type */
if((super_type=H5T_get_super(dtype))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for enumarate type")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for VL type")
/* Don't need alignment, offset information if this VL isn't a field of compound type. If it
* is, go to a few steps below to compute the information directly. */
if((nat_super_type = H5T_get_native_type(super_type, direction, NULL, NULL, &super_size))==NULL)
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index d9c519d..e2c811a 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -294,9 +294,8 @@ typedef struct H5T_opaque_t {
/* An array datatype */
typedef struct H5T_array_t {
size_t nelem; /* total number of elements in array */
- int ndims; /* member dimensionality */
+ unsigned ndims; /* member dimensionality */
size_t dim[H5S_MAX_RANK]; /* size in each dimension */
- int perm[H5S_MAX_RANK]; /* index permutation */
} H5T_array_t;
typedef enum H5T_state_t {
@@ -460,7 +459,7 @@ H5_DLL herr_t H5T_insert(const H5T_t *parent, const char *name, size_t offset,
H5_DLL H5T_t *H5T_enum_create(const H5T_t *parent);
H5_DLL herr_t H5T_enum_insert(const H5T_t *dt, const char *name, const void *value);
H5_DLL int H5T_get_array_ndims(H5T_t *dt);
-H5_DLL int H5T_get_array_dims(H5T_t *dt, hsize_t dims[], int perm[]);
+H5_DLL int H5T_get_array_dims(H5T_t *dt, hsize_t dims[]);
H5_DLL herr_t H5T_sort_value(const H5T_t *dt, int *map);
H5_DLL herr_t H5T_sort_name(const H5T_t *dt, int *map);
H5_DLL herr_t H5T_set_size(H5T_t *dt, size_t size);
@@ -1323,8 +1322,8 @@ H5_DLL H5T_t * H5T_vlen_create(const H5T_t *base);
H5_DLL htri_t H5T_vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc);
/* Array functions */
-H5_DLL H5T_t * H5T_array_create(H5T_t *base, int ndims,
- const hsize_t dim[/* ndims */], const int perm[/* ndims */]);
+H5_DLL H5T_t * H5T_array_create(H5T_t *base, unsigned ndims,
+ const hsize_t dim[/* ndims */]);
/* Compound functions */
H5_DLL H5T_t *H5T_get_member_type(const H5T_t *dt, unsigned membno);
diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h
index 44daec2..80e3124 100644
--- a/src/H5Tpublic.h
+++ b/src/H5Tpublic.h
@@ -526,8 +526,9 @@ H5_DLL herr_t H5Tenum_valueof(hid_t type, const char *name,
H5_DLL hid_t H5Tvlen_create(hid_t base_id);
/* Operations defined on array datatypes */
-H5_DLL hid_t H5Tarray_create(hid_t base_id, int ndims,
- const hsize_t dim[/* ndims */], const int perm[/* ndims */]);
+H5_DLL hid_t H5Tarray_create(hid_t base_id, unsigned ndims,
+ const hsize_t dim[/* ndims */],
+ const int perm[/* ndims */]);
H5_DLL int H5Tget_array_ndims(hid_t type_id);
H5_DLL int H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[]);