summaryrefslogtreecommitdiffstats
path: root/src/H5Ocache.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-03-10 20:02:55 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-03-10 20:02:55 (GMT)
commit1eb19fc8959e2f4580e7d48633f42a350ca229c3 (patch)
tree44813647b934cf0828a1bd743d4fc66f917e6566 /src/H5Ocache.c
parent753a42edf644632e4a8049ec41fdb5c368b18a21 (diff)
downloadhdf5-1eb19fc8959e2f4580e7d48633f42a350ca229c3.zip
hdf5-1eb19fc8959e2f4580e7d48633f42a350ca229c3.tar.gz
hdf5-1eb19fc8959e2f4580e7d48633f42a350ca229c3.tar.bz2
[svn-r13491] Description:
Reduce the size of the value used to store the # of bytes in the "payload" for chunk 0 of an object header. Tested on: FreeBSD/32 6.2 (duty)
Diffstat (limited to 'src/H5Ocache.c')
-rw-r--r--src/H5Ocache.c58
1 files changed, 50 insertions, 8 deletions
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 706497f..16e6278 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -279,7 +279,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
/* Flags */
oh->flags = *p++;
if(oh->flags & ~H5O_HDR_ALL_FLAGS)
- HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "unknown object header status flag(s)")
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "unknown object header status flag(s)")
/* Number of messages (to allocate initially) */
nmesgs = 1;
@@ -324,6 +324,28 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
oh->max_compact = H5O_CRT_ATTR_MAX_COMPACT_DEF;
oh->min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF;
} /* end else */
+
+ /* First chunk size */
+ switch(oh->flags & H5O_HDR_CHUNK0_SIZE) {
+ case 0: /* 1 byte size */
+ chunk_size = *p++;
+ break;
+
+ case 1: /* 2 byte size */
+ UINT16DECODE(p, chunk_size);
+ break;
+
+ case 2: /* 4 byte size */
+ UINT32DECODE(p, chunk_size);
+ break;
+
+ case 3: /* 8 byte size */
+ UINT64DECODE(p, chunk_size);
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad size for chunk 0")
+ } /* end switch */
} /* end if */
else {
/* Reset unused time fields */
@@ -332,10 +354,10 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
/* Reset unused attribute fields */
oh->max_compact = 0;
oh->min_dense = 0;
- } /* end else */
- /* First chunk size */
- UINT32DECODE(p, chunk_size);
+ /* First chunk size */
+ UINT32DECODE(p, chunk_size);
+ } /* end else */
/* Reserved, in version 1 */
if(H5O_VERSION_1 == oh->version)
@@ -412,8 +434,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
} /* end if */
else {
/* Read the chunk raw data */
- if(H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size,
- dxpl_id, oh->chunk[chunkno].image) < 0)
+ if(H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size, dxpl_id, oh->chunk[chunkno].image) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header data")
/* Point into chunk image to decode */
@@ -649,6 +670,8 @@ H5O_assert(oh);
* on the entire block of memory needs to be updated if anything is
* modified */
if(oh->version > H5O_VERSION_1) {
+ uint64_t chunk0_size = oh->chunk[0].size - H5O_SIZEOF_HDR(oh); /* Size of chunk 0's data */
+
/* Verify magic number */
HDassert(!HDmemcmp(p, H5O_HDR_MAGIC, H5O_SIZEOF_MAGIC));
p += H5O_SIZEOF_MAGIC;
@@ -676,8 +699,27 @@ H5O_assert(oh);
UINT16ENCODE(p, oh->min_dense);
} /* end if */
- /* Chunk size */
- UINT32ENCODE(p, (oh->chunk[0].size - H5O_SIZEOF_HDR(oh)));
+ /* First chunk size */
+ switch(oh->flags & H5O_HDR_CHUNK0_SIZE) {
+ case 0: /* 1 byte size */
+ *p++ = chunk0_size;
+ break;
+
+ case 1: /* 2 byte size */
+ UINT16ENCODE(p, chunk0_size);
+ break;
+
+ case 2: /* 4 byte size */
+ UINT32ENCODE(p, chunk0_size);
+ break;
+
+ case 3: /* 8 byte size */
+ UINT64ENCODE(p, chunk0_size);
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad size for chunk 0")
+ } /* end switch */
} /* end if */
else {
/* Version */