summaryrefslogtreecommitdiffstats
path: root/src/H5Osdspace.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-06-14 00:33:03 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-06-14 00:33:03 (GMT)
commit0e94f35c1ac7f4ab01a799bbaac98de01d5f09c7 (patch)
treed836dc086b0adb2bf7b1f2251b99bcfd9f48882d /src/H5Osdspace.c
parent986f3352516ce62e401516d65a39dc27612abf8e (diff)
downloadhdf5-0e94f35c1ac7f4ab01a799bbaac98de01d5f09c7.zip
hdf5-0e94f35c1ac7f4ab01a799bbaac98de01d5f09c7.tar.gz
hdf5-0e94f35c1ac7f4ab01a799bbaac98de01d5f09c7.tar.bz2
[svn-r8677] Purpose:
Code cleanup & optimization Description: Remove old structures that used a union to store information about the dataspace extent and just store the information directly in the dataspace extent itself. Remove ifdef'd references to permutation ordering in dataspaces. We'll definitely need more than this code if/when we implement this feature. Change allocation of dataspace information from calloc() to malloc(). Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.10 (sleipnir) w/parallel Too minor to require h5committest
Diffstat (limited to 'src/H5Osdspace.c')
-rw-r--r--src/H5Osdspace.c91
1 files changed, 29 insertions, 62 deletions
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index d558d33..35f00cc 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -124,8 +124,8 @@ H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "wrong version number in data space message");
/* Get rank */
- sdim->u.simple.rank = *p++;
- if (sdim->u.simple.rank>H5S_MAX_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 */
@@ -136,7 +136,7 @@ H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_
sdim->type = *p++;
else {
/* Set the dataspace type to be simple or scalar as appropriate */
- if(sdim->u.simple.rank>0)
+ if(sdim->rank>0)
sdim->type = H5S_SIMPLE;
else
sdim->type = H5S_SCALAR;
@@ -147,33 +147,25 @@ H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_
p += 4; /*reserved*/
- if (sdim->u.simple.rank > 0) {
- if (NULL==(sdim->u.simple.size=H5FL_ARR_MALLOC(hsize_t,sdim->u.simple.rank)))
+ if (sdim->rank > 0) {
+ if (NULL==(sdim->size=H5FL_ARR_MALLOC(hsize_t,sdim->rank)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- for (i = 0; i < sdim->u.simple.rank; i++)
- H5F_DECODE_LENGTH (f, p, sdim->u.simple.size[i]);
+ for (i = 0; i < sdim->rank; i++)
+ H5F_DECODE_LENGTH (f, p, sdim->size[i]);
if (flags & H5S_VALID_MAX) {
- if (NULL==(sdim->u.simple.max=H5FL_ARR_MALLOC(hsize_t,sdim->u.simple.rank)))
+ if (NULL==(sdim->max=H5FL_ARR_MALLOC(hsize_t,sdim->rank)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- for (i = 0; i < sdim->u.simple.rank; i++)
- H5F_DECODE_LENGTH (f, p, sdim->u.simple.max[i]);
+ for (i = 0; i < sdim->rank; i++)
+ H5F_DECODE_LENGTH (f, p, sdim->max[i]);
}
-#ifdef LATER
- if (flags & H5S_VALID_PERM) {
- if (NULL==(sdim->u.simple.perm=H5FL_ARR_MALLOC(hsize_t,sdim->u.simple.rank)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- for (i = 0; i < sdim->u.simple.rank; i++)
- H5F_DECODE_LENGTH (f, p, sdim->u.simple.perm[i]);
- }
-#endif /* LATER */
}
/* 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->u.simple.rank; i++)
- sdim->nelem*=sdim->u.simple.size[i];
+ for(i=0, sdim->nelem=1; i<sdim->rank; i++)
+ sdim->nelem*=sdim->size[i];
}
}
@@ -237,19 +229,15 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *mesg)
assert(sdim);
/* set flags */
- if (sdim->u.simple.max)
+ if (sdim->max)
flags |= H5S_VALID_MAX;
-#ifdef LATER
- if (sdim->u.simple.perm)
- flags |= H5S_VALID_PERM;
-#endif
/* encode */
if(sdim->type!=H5S_NULL)
*p++ = H5O_SDSPACE_VERSION;
else
*p++ = H5O_SDSPACE_VERSION_2;
- *p++ = sdim->u.simple.rank;
+ *p++ = sdim->rank;
*p++ = flags;
if(sdim->type!=H5S_NULL)
*p++ = 0; /*reserved*/
@@ -260,19 +248,13 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *mesg)
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
- if (sdim->u.simple.rank > 0) {
- for (u = 0; u < sdim->u.simple.rank; u++)
- H5F_ENCODE_LENGTH (f, p, sdim->u.simple.size[u]);
+ 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->u.simple.rank; u++)
- H5F_ENCODE_LENGTH (f, p, sdim->u.simple.max[u]);
+ for (u = 0; u < sdim->rank; u++)
+ H5F_ENCODE_LENGTH (f, p, sdim->max[u]);
}
-#ifdef LATER
- if (flags & H5S_VALID_PERM) {
- for (u = 0; u < sdim->u.simple.rank; u++)
- H5F_ENCODE_LENGTH (f, p, sdim->u.simple.perm[u]);
- }
-#endif
}
done:
@@ -360,15 +342,10 @@ H5O_sdspace_size(H5F_t *f, const void *mesg)
FUNC_ENTER_NOAPI(H5O_sdspace_size, 0);
/* add in the dimension sizes */
- ret_value += space->u.simple.rank * H5F_SIZEOF_SIZE (f);
+ ret_value += space->rank * H5F_SIZEOF_SIZE (f);
/* add in the space for the maximum dimensions, if they are present */
- ret_value += space->u.simple.max ? space->u.simple.rank * H5F_SIZEOF_SIZE (f) : 0;
-
-#ifdef LATER
- /* add in the space for the dimension permutations, if they are present */
- ret_value += space->u.simple.perm ? space->u.simple.rank * 4 : 0;
-#endif
+ ret_value += space->max ? space->rank * H5F_SIZEOF_SIZE (f) : 0;
done:
FUNC_LEAVE_NOAPI(ret_value);
@@ -472,38 +449,28 @@ H5O_sdspace_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg,
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Rank:",
- (unsigned long) (sdim->u.simple.rank));
+ (unsigned long) (sdim->rank));
- if(sdim->u.simple.rank>0) {
+ if(sdim->rank>0) {
HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:");
- for (u = 0; u < sdim->u.simple.rank; u++)
- HDfprintf (stream, "%s%Hu", u?", ":"", sdim->u.simple.size[u]);
+ for (u = 0; u < sdim->rank; u++)
+ HDfprintf (stream, "%s%Hu", u?", ":"", sdim->size[u]);
HDfprintf (stream, "}\n");
HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:");
- if (sdim->u.simple.max) {
+ if (sdim->max) {
HDfprintf (stream, "{");
- for (u = 0; u < sdim->u.simple.rank; u++) {
- if (H5S_UNLIMITED==sdim->u.simple.max[u]) {
+ for (u = 0; u < sdim->rank; u++) {
+ if (H5S_UNLIMITED==sdim->max[u]) {
HDfprintf (stream, "%sINF", u?", ":"");
} else {
- HDfprintf (stream, "%s%Hu", u?", ":"", sdim->u.simple.max[u]);
+ HDfprintf (stream, "%s%Hu", u?", ":"", sdim->max[u]);
}
}
HDfprintf (stream, "}\n");
} else {
HDfprintf (stream, "CONSTANT\n");
}
-
-#ifdef LATER
- if (sdim->u.simple.perm) {
- HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Perm:");
- for (u = 0; u < sdim->u.simple.rank; u++) {
- HDfprintf (stream, "%s%lu", u?", ":"",
- (unsigned long) (sdim->u.simple.perm[u]));
- }
- }
-#endif
} /* end if */
done: