mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r94] Removed encode/decode from fast/cache message functions.
Fixed uninitialized bytes appearing in the data file object header.
This commit is contained in:
parent
c7ee2a5708
commit
0b52a1324e
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
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(ent->cache.sdata.dim==NULL)
|
||||
modified = BTRUE;
|
||||
else
|
||||
{
|
||||
for(u=0; u<sdim->rank; u++)
|
||||
if (ent->cache.sdata.dim[u] != sdim->size[u])
|
||||
{
|
||||
/* 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() */
|
||||
|
||||
|
@ -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 (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;
|
||||
} /* end if */
|
||||
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;
|
||||
} /* end if */
|
||||
} /* end else */
|
||||
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() */
|
||||
|
Loading…
Reference in New Issue
Block a user