summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1997-09-17 15:03:52 (GMT)
committerRobb Matzke <matzke@llnl.gov>1997-09-17 15:03:52 (GMT)
commit0b52a1324e8f9736ce5b4686cbec14d6102abbc9 (patch)
treead70420a896c5e08215026d4968acf284828d4f9
parentc7ee2a5708df2f88ce439cda028886ee20593b77 (diff)
downloadhdf5-0b52a1324e8f9736ce5b4686cbec14d6102abbc9.zip
hdf5-0b52a1324e8f9736ce5b4686cbec14d6102abbc9.tar.gz
hdf5-0b52a1324e8f9736ce5b4686cbec14d6102abbc9.tar.bz2
[svn-r94] Removed encode/decode from fast/cache message functions.
Fixed uninitialized bytes appearing in the data file object header.
-rw-r--r--src/H5Gprivate.h8
-rw-r--r--src/H5O.c2
-rw-r--r--src/H5Osdim.c92
-rw-r--r--src/H5Osdtyp.c86
4 files changed, 86 insertions, 102 deletions
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index d9457b1..e6f5df4 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -63,10 +63,10 @@ typedef struct H5G_entry_t {
union {
struct {
struct {
- uint8 length;
- uint8 arch;
- uint16 type;
- }nt ; /*number type */
+ uint8 length;
+ uint8 arch;
+ uint16 type;
+ } nt ; /*number type */
uint32 ndim; /*number of dimensions */
uint32 dim[4]; /*dimension sizes */
} sdata;
diff --git a/src/H5O.c b/src/H5O.c
index 95cb57a..75a5993 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -121,7 +121,7 @@ H5O_new (hdf5_file_t *f, intn nlink, size_t size_hint)
oh->chunk[0].dirty = TRUE;
oh->chunk[0].addr = addr + H5O_SIZEOF_HDR(f);
oh->chunk[0].size = size_hint;
- oh->chunk[0].image = H5MM_xmalloc (size_hint);
+ oh->chunk[0].image = H5MM_xcalloc (1, size_hint);
/* create the message list and initialize the first message */
oh->nmesgs = 1;
diff --git a/src/H5Osdim.c b/src/H5Osdim.c
index 2d578a2..f8d8a73 100644
--- a/src/H5Osdim.c
+++ b/src/H5Osdim.c
@@ -211,26 +211,25 @@ H5O_sim_dim_fast (const H5G_entry_t *ent, void *mesg)
{
H5O_sim_dim_t *sdim = (H5O_sim_dim_t *)mesg;
uintn u; /* local counting variable */
- const uint8 *p;
FUNC_ENTER (H5O_sim_dim_fast, NULL, NULL);
/* check args */
assert (ent);
- if (H5G_CACHED_SDATA==ent->type)
- {
- if (!sdim) sdim = H5MM_xcalloc (1, sizeof(H5O_sim_dim_t));
- p=(const uint8 *)&ent->cache.sdata.ndim;
- UINT32DECODE(p,sdim->rank);
- sdim->dim_flags=0; /* cached dimensions never have max. dims or permutation vectors */
- sdim->size=H5MM_xmalloc(sizeof(uint32)*sdim->rank);
- for(u=0; u<sdim->rank; u++)
- UINT32DECODE(p,sdim->size[u]);
- } /* end if */
- else
+ if (H5G_CACHED_SDATA==ent->type) {
+ if (!sdim) sdim = H5MM_xcalloc (1, sizeof(H5O_sim_dim_t));
+ sdim->rank = ent->cache.sdata.ndim;
+ assert (sdim->rank<=NELMTS (ent->cache.sdata.dim));
+ sdim->dim_flags = 0;
+ sdim->size = H5MM_xmalloc (sizeof(uint32) * sdim->rank);
+ for (u=0; u<sdim->rank; u++) {
+ sdim->size[u] = ent->cache.sdata.dim[u];
+ }
+ } else {
sdim = NULL;
-
+ }
+
FUNC_LEAVE (sdim);
} /* end H5O_sim_dim_fast() */
@@ -257,7 +256,6 @@ H5O_sim_dim_cache (H5G_entry_t *ent, const void *mesg)
{
const H5O_sim_dim_t *sdim = (const H5O_sim_dim_t *)mesg;
uintn u; /* Local counting variable */
- uint8 *p;
hbool_t modified = BFALSE;
FUNC_ENTER (H5O_sim_dim_cache, NULL, BFAIL);
@@ -266,42 +264,40 @@ H5O_sim_dim_cache (H5G_entry_t *ent, const void *mesg)
assert (ent);
assert (sdim);
- /*
- * We do this in two steps so Purify doesn't complain about
- * uninitialized memory reads even though they don't bother
- * anything.
- */
- p=(uint8 *)&(ent->cache.sdata);
- if (H5G_CACHED_SDATA != ent->type)
- {
- modified = BTRUE;
- ent->type = H5G_CACHED_SDATA;
- UINT32ENCODE(p,sdim->rank);
- for(u=0; u<=sdim->rank; u++)
- UINT32ENCODE(p,sdim->size[u]);
- } /* end if */
- else
- {
- if(ent->cache.sdata.ndim!= sdim->rank)
- {
- modified = BTRUE;
- ent->cache.sdata.ndim = sdim->rank;
- } /* end if */
-
- /* Check each dimension */
- if(ent->cache.sdata.dim==NULL)
- modified = BTRUE;
- else
- {
- for(u=0; u<sdim->rank; u++)
- if (ent->cache.sdata.dim[u] != sdim->size[u])
- {
+ if (sdim->rank <= NELMTS (ent->cache.sdata.dim)) {
+ if (H5G_CACHED_SDATA != ent->type) {
+ modified = BTRUE;
+ ent->type = H5G_CACHED_SDATA;
+ ent->cache.sdata.ndim = sdim->rank;
+ for (u=0; u<=sdim->rank; u++) {
+ ent->cache.sdata.dim[u] = sdim->size[u];
+ }
+ } else {
+ if(ent->cache.sdata.ndim!= sdim->rank) {
+ modified = BTRUE;
+ ent->cache.sdata.ndim = sdim->rank;
+ }
+
+ /* Check each dimension */
+ if (NULL==ent->cache.sdata.dim) {
+ modified = BTRUE;
+ } else {
+ for (u=0; u<sdim->rank; u++) {
+ if (ent->cache.sdata.dim[u] != sdim->size[u]) {
modified = BTRUE;
ent->cache.sdata.dim[u] = sdim->size[u];
- } /* end if */
- } /* end else */
- } /* end else */
-
+ }
+ }
+ }
+ }
+ } else if (H5G_CACHED_SDATA == ent->type) {
+ /*
+ * Number of dimensions is too large to cache.
+ */
+ modified = TRUE;
+ ent->type = H5G_NOTHING_CACHED;
+ }
+
FUNC_LEAVE (modified);
} /* end H5O_sim_dim_cache() */
diff --git a/src/H5Osdtyp.c b/src/H5Osdtyp.c
index dc571eb..19af66b 100644
--- a/src/H5Osdtyp.c
+++ b/src/H5Osdtyp.c
@@ -168,27 +168,22 @@ static void *
H5O_sim_dtype_fast (const H5G_entry_t *ent, void *mesg)
{
H5O_sim_dtype_t *sdtype = (H5O_sim_dtype_t *)mesg;
- const uint8 *p;
FUNC_ENTER (H5O_sim_dtype_fast, NULL, NULL);
/* check args */
assert (ent);
- if (H5G_CACHED_SDATA==ent->type)
- {
- if (!sdtype)
- if((sdtype = H5MM_xcalloc (1, sizeof(H5O_sim_dtype_t)))!=NULL)
- {
- p=(const uint8 *)&ent->cache.sdata.nt;
- sdtype->len=*p++;
- sdtype->arch=*p++;
- UINT16DECODE(p,sdtype->base);
- sdtype->base=MAKE_ATOM(H5_DATATYPE,sdtype->base); /* convert into atomic base type */
- } /* end if */
- } /* end if */
- else
+ if (H5G_CACHED_SDATA==ent->type) {
+ if (!sdtype) sdtype = H5MM_xcalloc (1, sizeof(H5O_sim_dtype_t));
+ sdtype->len = ent->cache.sdata.nt.length;
+ sdtype->arch = ent->cache.sdata.nt.arch;
+
+ /* Convert into atomic base type. */
+ sdtype->base = MAKE_ATOM (H5_DATATYPE, ent->cache.sdata.nt.type);
+ } else {
sdtype = NULL;
+ }
FUNC_LEAVE (sdtype);
} /* end H5O_sim_dtype_fast() */
@@ -215,7 +210,6 @@ static hbool_t
H5O_sim_dtype_cache (H5G_entry_t *ent, const void *mesg)
{
const H5O_sim_dtype_t *sdtype = (const H5O_sim_dtype_t *)mesg;
- uint8 *p;
hbool_t modified = BFALSE;
FUNC_ENTER (H5O_sim_dtype_cache, NULL, BFAIL);
@@ -224,40 +218,34 @@ H5O_sim_dtype_cache (H5G_entry_t *ent, const void *mesg)
assert (ent);
assert (sdtype);
- /*
- * We do this in two steps so Purify doesn't complain about
- * uninitialized memory reads even though they don't bother
- * anything.
- */
- p=(uint8 *)&(ent->cache.sdata);
- if (H5G_CACHED_SDATA != ent->type)
- {
- modified = BTRUE;
- ent->type = H5G_CACHED_SDATA;
- *p++=sdtype->len;
- *p++=sdtype->arch;
- UINT16ENCODE(p,sdtype->base);
- } /* end if */
- else
- {
- if(ent->cache.sdata.nt.length != sdtype->len)
- {
- modified = BTRUE;
- ent->cache.sdata.nt.length = sdtype->len;
- } /* end if */
-
- if (ent->cache.sdata.nt.arch != sdtype->arch)
- {
- modified = BTRUE;
- ent->cache.sdata.nt.arch = sdtype->arch;
- } /* end if */
-
- if (ent->cache.sdata.nt.type != (uint16)sdtype->base)
- {
- modified = BTRUE;
- ent->cache.sdata.nt.type = (uint16)sdtype->base;
- } /* end if */
- } /* end else */
+ if (H5G_CACHED_SDATA != ent->type) {
+ /*
+ * No sdata cached yet.
+ */
+ modified = BTRUE;
+ ent->type = H5G_CACHED_SDATA;
+ ent->cache.sdata.nt.length = sdtype->len;
+ ent->cache.sdata.nt.arch = sdtype->arch;
+ ent->cache.sdata.nt.type = sdtype->base;
+ } else {
+ /*
+ * Some sdata already cached.
+ */
+ if (ent->cache.sdata.nt.length != sdtype->len) {
+ modified = BTRUE;
+ ent->cache.sdata.nt.length = sdtype->len;
+ }
+
+ if (ent->cache.sdata.nt.arch != sdtype->arch) {
+ modified = BTRUE;
+ ent->cache.sdata.nt.arch = sdtype->arch;
+ }
+
+ if (ent->cache.sdata.nt.type != (uint16)sdtype->base) {
+ modified = BTRUE;
+ ent->cache.sdata.nt.type = (uint16)sdtype->base;
+ }
+ }
FUNC_LEAVE (modified);
} /* end H5O_sim_dtype_cache() */