summaryrefslogtreecommitdiffstats
path: root/src/H5O.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/H5O.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/H5O.c')
-rw-r--r--src/H5O.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 9ac1dd1..775ee4d 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -677,6 +677,8 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id,
/* Initialize version-specific fields */
if(oh->version > H5O_VERSION_1) {
+ size_t tent_oh_size; /* Tentative size of object header */
+
/* Initialize all time fields with current time, if we are storing them */
if(oh->flags & H5O_HDR_STORE_TIMES)
oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now();
@@ -698,6 +700,30 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id,
/* Check for non-default attribute storage phase change values */
if(oh->max_compact != H5O_CRT_ATTR_MAX_COMPACT_DEF || oh->min_dense != H5O_CRT_ATTR_MIN_DENSE_DEF)
oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE;
+
+ /* Determine correct value for chunk #0 size bits */
+
+ /* See if only 1 byte is enough */
+ tent_oh_size = H5O_SIZEOF_HDR(oh) + size_hint;
+ if(tent_oh_size > 255) {
+ uint8_t old_oh_flags = oh->flags; /* Temporary object header flags */
+
+ /* Need more than 1 byte, see if 2 bytes is enough */
+ oh->flags |= H5O_HDR_CHUNK0_2;
+ tent_oh_size = H5O_SIZEOF_HDR(oh) + size_hint;
+ if(tent_oh_size > 65535) {
+ /* Need more than 2 bytes, see if 4 bytes is enough */
+ oh->flags = old_oh_flags;
+ oh->flags |= H5O_HDR_CHUNK0_4;
+ tent_oh_size = H5O_SIZEOF_HDR(oh) + size_hint;
+ if(tent_oh_size > 4294967295) {
+ /* Use 8 bytes */
+ /* (Should probably have check for using more than 8 bytes... :-) */
+ oh->flags = old_oh_flags;
+ oh->flags |= H5O_HDR_CHUNK0_8;
+ } /* end if */
+ } /* end if */
+ } /* end if */
} /* end if */
else {
/* Reset unused time fields */