summaryrefslogtreecommitdiffstats
path: root/src/H5Osdspace.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-01-30 23:32:28 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-01-30 23:32:28 (GMT)
commit374e5ae39b6f05469c1bcbdcaf0a473f1dde1385 (patch)
tree3284232ef8b21758da14fe63347b903d3883c3c4 /src/H5Osdspace.c
parentd9329a23aab4d941956ac421b11eb009a2deb32b (diff)
downloadhdf5-374e5ae39b6f05469c1bcbdcaf0a473f1dde1385.zip
hdf5-374e5ae39b6f05469c1bcbdcaf0a473f1dde1385.tar.gz
hdf5-374e5ae39b6f05469c1bcbdcaf0a473f1dde1385.tar.bz2
[svn-r209] Changes since 19980130
---------------------- ./INSTALL Added instructions for which C flags to set for debugging. ./src/H5C.c ./src/H5Cpublic.h H5Cset_chunk() takes const pointer. ./src/H5D.c ./src/H5Dprivate.h ./src/H5Dpublic.h Added H5Dextend() to extend the dimensions of a dataset. ./src/H5Osdspace.c ./src/H5P.c ./src/H5Pprivate.h ./src/H5Ppublic.h ./test/cmpd_dset.c ./test/dsets.c ./test/th5p.c Added the optional `maxdims' argument to H5Pcreate_simple() and defined constant H5P_UNLIMITED which can appear in the maxdims. Added `const' to arguments. Implemented H5Pcopy() Removed the unused file argument from H5P_modify. Added H5P_extend(). Removed the `flags' field from simple data types and we determine if the `max' or `perm' arrays are valid by looking at the pointer. Cleaned up the H5O_sdspace_debug output. ./src/H5T.c Fixed a printf format. ./MANIFEST ./test/Makefile.in ./test/extend.c [NEW] Added a test for multi-dimensional unlimited dimensions.
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);
}