summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-12-04 17:32:43 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-12-04 17:32:43 (GMT)
commita21800d2f25ecd848285ddb00391219fe3b764d3 (patch)
treee1267b801d4da408d0bf70c758bf12808cbfdf3a /src
parentc76724db391db20392c19feed3430da2a8059340 (diff)
downloadhdf5-a21800d2f25ecd848285ddb00391219fe3b764d3.zip
hdf5-a21800d2f25ecd848285ddb00391219fe3b764d3.tar.gz
hdf5-a21800d2f25ecd848285ddb00391219fe3b764d3.tar.bz2
[svn-r13020] Description:
Make number of attributes tracking in object header prefix "live" Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src')
-rw-r--r--src/H5O.c3
-rw-r--r--src/H5Oalloc.c3
-rw-r--r--src/H5Odbg.c10
-rw-r--r--src/H5Omessage.c30
-rw-r--r--src/H5Opkg.h18
5 files changed, 37 insertions, 27 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 6b5c853..d68efd2 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1875,11 +1875,8 @@ H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id)
if(curr_msg->flags & H5O_MSG_FLAG_SHARED) \
oinfo->hdr.msg_shared |= type_flag;
} /* end for */
-#ifdef LATER
-/* XXX: Uncomment this when attributes are tracked by the object header */
if(oh->version > H5O_VERSION_1)
HDassert(oh->nattrs == oinfo->num_attrs);
-#endif /* LATER */
/* Iterate over all the chunks, adding any gaps to the free space */
oinfo->hdr.hdr_size = 0;
diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c
index af1a4a0..1807a14 100644
--- a/src/H5Oalloc.c
+++ b/src/H5Oalloc.c
@@ -893,9 +893,6 @@ H5O_alloc(H5F_t *f,
/* Mark the object header as modified */
*oh_flags_ptr |= H5AC__DIRTIED_FLAG;
-#ifdef H5O_DEBUG
-H5O_assert(oh);
-#endif /* H5O_DEBUG */
/* Set return value */
ret_value = idx;
diff --git a/src/H5Odbg.c b/src/H5Odbg.c
index 88178a1..a016ec3 100644
--- a/src/H5Odbg.c
+++ b/src/H5Odbg.c
@@ -93,6 +93,7 @@ H5O_assert(const H5O_t *oh)
{
H5O_mesg_t *curr_msg; /* Pointer to current message to examine */
H5O_mesg_t *tmp_msg; /* Pointer to temporary message to examine */
+ hsize_t num_attrs; /* Number of attributes on object */
size_t meta_space; /* Size of header metadata */
size_t mesg_space; /* Size of message raw data */
size_t free_space; /* Size of free space in header */
@@ -101,11 +102,12 @@ H5O_assert(const H5O_t *oh)
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_assert)
- /* Initialize the space tracking variables */
+ /* Initialize the tracking variables */
hdr_size = 0;
meta_space = H5O_SIZEOF_HDR_OH(oh) + (H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1));
mesg_space = 0;
free_space = 0;
+ num_attrs = 0;
/* Loop over all chunks in object header */
for(u = 0; u < oh->nchunks; u++) {
@@ -137,6 +139,10 @@ H5O_assert(const H5O_t *oh)
/* Loop over all messages in object header */
for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
+ /* Check for attribute message */
+ if(H5O_ATTR_ID == curr_msg->type->id)
+ num_attrs++;
+
/* Accumulate information, based on the type of message */
if(H5O_NULL_ID == curr_msg->type->id)
free_space += H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size;
@@ -168,6 +174,8 @@ H5O_assert(const H5O_t *oh)
HDassert(!(tmp_msg->raw >= curr_msg->raw && tmp_msg->raw < (curr_msg->raw + curr_msg->raw_size)));
} /* end for */
} /* end for */
+ if(oh->version > H5O_VERSION_1)
+ HDassert(oh->nattrs == num_attrs);
/* Sanity check that all the bytes are accounted for */
HDassert(hdr_size == (free_space + meta_space + mesg_space + oh->skipped_mesg_size));
diff --git a/src/H5Omessage.c b/src/H5Omessage.c
index 208d078..eff744e 100644
--- a/src/H5Omessage.c
+++ b/src/H5Omessage.c
@@ -44,6 +44,24 @@
/* Local Macros */
/****************/
+/* Load native information for a message, if it's not already present */
+/* (Only works for messages with decode callback) */
+#define H5O_LOAD_NATIVE(F, DXPL, MSG, ERR) \
+ if(NULL == (MSG)->native) { \
+ const H5O_msg_class_t *decode_type; \
+ \
+ /* Check for shared message */ \
+ if((MSG)->flags & H5O_MSG_FLAG_SHARED) \
+ decode_type = H5O_MSG_SHARED; \
+ else \
+ decode_type = (MSG)->type; \
+ \
+ /* Decode the message */ \
+ HDassert(decode_type->decode); \
+ if(NULL == ((MSG)->native = (decode_type->decode)((F), (DXPL), (MSG)->raw))) \
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \
+ } /* end if */
+
/******************/
/* Local Typedefs */
@@ -226,6 +244,10 @@ H5O_msg_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id,
/* Write the information to the message */
if(H5O_write_mesg(f, dxpl_id, oh, idx, new_type, new_mesg, mesg_flags, update_flags, oh_flags_ptr) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to write message")
+
+ /* If the message added is an attribute, increment count */
+ if(H5O_ATTR_ID == type_id && oh->version > H5O_VERSION_1)
+ oh->nattrs++;
#ifdef H5O_DEBUG
H5O_assert(oh);
#endif /* H5O_DEBUG */
@@ -1055,8 +1077,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
- unsigned sequence, unsigned *oh_flags_ptr, void *_udata/*in,out*/)
+H5O_msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence,
+ unsigned *oh_flags_ptr, void *_udata/*in,out*/)
{
H5O_iter_ud1_t *udata = (H5O_iter_ud1_t *)_udata; /* Operator user data */
htri_t try_remove = FALSE; /* Whether to try removing a message */
@@ -1092,6 +1114,10 @@ H5O_msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
if(H5O_release_mesg(udata->f, udata->dxpl_id, oh, mesg, TRUE, udata->adj_link) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to convert into null message")
+ /* If the message removed is an attribute, decrement count */
+ if(H5O_ATTR_ID == mesg->type->id && oh->version > H5O_VERSION_1)
+ oh->nattrs--;
+
/* Indicate that the object header was modified */
*oh_flags_ptr |= H5AC__DIRTIED_FLAG;
} /* end else */
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index a23b311..55c31f3 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -151,24 +151,6 @@
#define H5O_SIZEOF_CHKSUM_OH(O) \
H5O_SIZEOF_CHKSUM_VERS((O)->version)
-/* Load native information for a message, if it's not already present */
-/* (Only works for messages with decode callback) */
-#define H5O_LOAD_NATIVE(F, DXPL, MSG, ERR) \
- if(NULL == (MSG)->native) { \
- const H5O_msg_class_t *decode_type; \
- \
- /* Check for shared message */ \
- if((MSG)->flags & H5O_MSG_FLAG_SHARED) \
- decode_type = H5O_MSG_SHARED; \
- else \
- decode_type = (MSG)->type; \
- \
- /* Decode the message */ \
- HDassert(decode_type->decode); \
- if(NULL == ((MSG)->native = (decode_type->decode)((F), (DXPL), (MSG)->raw))) \
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \
- } /* end if */
-
struct H5O_msg_class_t {
unsigned id; /*message type ID on disk */
const char *name; /*for debugging */