summaryrefslogtreecommitdiffstats
path: root/src/H5Osdspace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Osdspace.c')
-rw-r--r--src/H5Osdspace.c115
1 files changed, 64 insertions, 51 deletions
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 26330df..55c71a8 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -34,9 +34,7 @@ static herr_t H5O_sdspace_debug(H5F_t *f, const void *_mesg,
FILE * stream, intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_SDSPACE[1] =
-{
- {
+const H5O_class_t H5O_SDSPACE[1] = {{
H5O_SDSPACE_ID, /* message id number */
"simple_dspace", /* message name for debugging */
sizeof(H5P_simple_t), /* native message size */
@@ -46,7 +44,7 @@ const H5O_class_t H5O_SDSPACE[1] =
H5O_sdspace_size, /* size of symbol table entry */
NULL, /* default reset method */
H5O_sdspace_debug, /* debug the message */
- }};
+}};
/* Is the interface initialized? */
static hbool_t interface_initialize_g = FALSE;
@@ -73,9 +71,10 @@ static hbool_t interface_initialize_g = FALSE;
static void *
H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5P_simple_t *sdim = NULL; /* New simple dimensionality structure */
- uintn u; /* local counting variable */
-
+ H5P_simple_t *sdim = NULL; /* New simple dimensionality structure */
+ uintn u; /* local counting variable */
+ uintn flags;
+
FUNC_ENTER(H5O_sdspace_decode, NULL);
/* check args */
@@ -86,17 +85,17 @@ H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p)
/* decode */
if ((sdim = H5MM_xcalloc(1, sizeof(H5P_simple_t))) != NULL) {
UINT32DECODE(p, sdim->rank);
- UINT32DECODE(p, sdim->dim_flags);
+ UINT32DECODE(p, flags);
if (sdim->rank > 0) {
sdim->size = H5MM_xmalloc(sizeof(uint32) * sdim->rank);
for (u = 0; u < sdim->rank; u++)
UINT32DECODE(p, sdim->size[u]);
- if (sdim->dim_flags & 0x01) {
+ if (flags & 0x01) {
sdim->max = H5MM_xmalloc(sizeof(uint32) * sdim->rank);
for (u = 0; u < sdim->rank; u++)
UINT32DECODE(p, sdim->max[u]);
} /* end if */
- if (sdim->dim_flags & 0x02) {
+ if (flags & 0x02) {
sdim->perm = H5MM_xmalloc(sizeof(uint32) * sdim->rank);
for (u = 0; u < sdim->rank; u++)
UINT32DECODE(p, sdim->perm[u]);
@@ -134,8 +133,9 @@ H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p)
static herr_t
H5O_sdspace_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
{
- const H5P_simple_t *sdim = (const H5P_simple_t *) mesg;
- uintn u; /* Local counting variable */
+ const H5P_simple_t *sdim = (const H5P_simple_t *) mesg;
+ uintn u; /* Local counting variable */
+ uintn flags = 0;
FUNC_ENTER(H5O_sdspace_encode, FAIL);
@@ -145,17 +145,21 @@ H5O_sdspace_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
assert(p);
assert(sdim);
+ /* set flags */
+ if (sdim->max) flags |= 0x01;
+ if (sdim->perm) flags |= 0x02;
+
/* encode */
UINT32ENCODE(p, sdim->rank);
- UINT32ENCODE(p, sdim->dim_flags);
+ UINT32ENCODE(p, flags);
if (sdim->rank > 0) {
for (u = 0; u < sdim->rank; u++)
UINT32ENCODE(p, sdim->size[u]);
- if (sdim->dim_flags & 0x01) {
+ if (flags & 0x01) {
for (u = 0; u < sdim->rank; u++)
UINT32ENCODE(p, sdim->max[u]);
} /* end if */
- if (sdim->dim_flags & 0x02) {
+ if (flags & 0x02) {
for (u = 0; u < sdim->rank; u++)
UINT32ENCODE(p, sdim->perm[u]);
} /* end if */
@@ -193,24 +197,20 @@ H5O_sdspace_copy(const void *mesg, void *dest)
/* deep copy -- pointed-to values are copied also */
HDmemcpy(dst, src, sizeof(H5P_simple_t));
- if (src->size)
- dst->size = H5MM_xcalloc(src->rank, sizeof(uint32));
- if (src->max)
- dst->max = H5MM_xcalloc(src->rank, sizeof(uint32));
- if (src->perm)
- dst->perm = H5MM_xcalloc(src->rank, sizeof(uint32));
+
+ if (src->size) {
+ dst->size = H5MM_xcalloc(src->rank, sizeof(src->size[0]));
+ HDmemcpy (dst->size, src->size, src->rank*sizeof(src->size[0]));
+ }
+ if (src->max) {
+ dst->max = H5MM_xcalloc(src->rank, sizeof(src->max[0]));
+ HDmemcpy (dst->max, src->max, src->rank*sizeof(src->max[0]));
+ }
+ if (src->perm) {
+ dst->perm = H5MM_xcalloc(src->rank, sizeof(src->perm[0]));
+ HDmemcpy (dst->perm, src->perm, src->rank*sizeof(src->perm[0]));
+ }
- if (src->rank > 0) {
- HDmemcpy(dst->size, src->size, src->rank * sizeof(uint32));
- /* Check for maximum dimensions and copy those */
- if ((src->dim_flags & 0x01) > 0) {
- HDmemcpy(dst->max, src->max, src->rank * sizeof(uint32));
- } /* end if */
- /* Check for dimension permutation and copy those */
- if ((src->dim_flags & 0x02) > 0) {
- HDmemcpy(dst->perm, src->perm, src->rank * sizeof(uint32));
- } /* end if */
- } /* end if */
FUNC_LEAVE((void *) dst);
}
@@ -239,8 +239,8 @@ H5O_sdspace_size(H5F_t *f, const void *mesg)
FUNC_ENTER(H5O_sim_dtype_size, FAIL);
ret_value += sdim->rank * 4; /* add in the dimension sizes */
- ret_value += ((sdim->dim_flags & 0x01) > 0) * sdim->rank * 4; /* add in the space for the maximum dimensions, if they are present */
- ret_value += ((sdim->dim_flags & 0x02) > 0) * sdim->rank * 4; /* add in the space for the dimension permutations, if they are present */
+ ret_value += sdim->max ? sdim->rank * 4 : 0; /* add in the space for the maximum dimensions, if they are present */
+ ret_value += sdim->perm ? sdim->rank * 4 : 0; /* add in the space for the dimension permutations, if they are present */
FUNC_LEAVE(ret_value);
}
@@ -282,23 +282,36 @@ H5O_sdspace_debug(H5F_t *f, const void *mesg, FILE * stream,
fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Rank:",
(unsigned long) (sdim->rank));
- fprintf(stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Flags:",
- (unsigned long) (sdim->dim_flags));
- for (u = 0; u < sdim->rank; u++)
- fprintf(stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Dim Size:",
- (unsigned long) (sdim->size[u]));
- if (sdim->dim_flags & 0x01)
- for (u = 0; u < sdim->rank; u++)
- fprintf(stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Dim Max:",
- (unsigned long) (sdim->max[u]));
- if (sdim->dim_flags & 0x02)
- for (u = 0; u < sdim->rank; u++)
- fprintf(stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Dim Perm:",
- (unsigned long) (sdim->perm[u]));
+
+ fprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:");
+ for (u = 0; u < sdim->rank; u++) {
+ fprintf (stream, "%s%lu", u?", ":"", (unsigned long)(sdim->size[u]));
+ }
+ fprintf (stream, "}\n");
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:");
+ if (sdim->max) {
+ fprintf (stream, "{");
+ for (u = 0; u < sdim->rank; u++) {
+ if (H5P_UNLIMITED==sdim->max[u]) {
+ fprintf (stream, "%sINF", u?", ":"");
+ } else {
+ fprintf (stream, "%s%lu\n", u?", ":"",
+ (unsigned long) (sdim->max[u]));
+ }
+ }
+ fprintf (stream, "}\n");
+ } else {
+ fprintf (stream, "CONSTANT\n");
+ }
+
+ if (sdim->perm) {
+ fprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Perm:");
+ for (u = 0; u < sdim->rank; u++) {
+ fprintf (stream, "%s%lu", u?", ":"",
+ (unsigned long) (sdim->perm[u]));
+ }
+ }
FUNC_LEAVE(SUCCEED);
}