summaryrefslogtreecommitdiffstats
path: root/src/H5O.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5O.c')
-rw-r--r--src/H5O.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 1989077..ba8033f 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -91,6 +91,7 @@ static H5O_t *H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_udata
static herr_t H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh);
static herr_t H5O_dest(H5F_t *f, H5O_t *oh);
static herr_t H5O_clear(H5F_t *f, H5O_t *oh, hbool_t destroy);
+static herr_t H5O_compute_size(H5F_t *f, H5O_t *oh, size_t *size_ptr);
/* H5O inherits cache-like properties from H5AC */
static const H5AC_class_t H5AC_OHDR[1] = {{
@@ -99,6 +100,7 @@ static const H5AC_class_t H5AC_OHDR[1] = {{
(H5AC_flush_func_t)H5O_flush,
(H5AC_dest_func_t)H5O_dest,
(H5AC_clear_func_t)H5O_clear,
+ (H5AC_size_func_t)H5O_compute_size,
}};
/* ID to type mapping */
@@ -893,6 +895,60 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O_compute_size
+ *
+ * Purpose: Compute the size in bytes of the specified instance of
+ * H5O_t on disk, and return it in *len_ptr. On failure,
+ * the value of *len_ptr is undefined.
+ *
+ * The value returned will probably be low unless the object
+ * has just been flushed, as we simply total up the size of
+ * the header with the sizes of the chunks. Thus any message
+ * that has been added since the last flush will not be
+ * reflected in the total.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: John Mainzer
+ * 5/13/04
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_compute_size(H5F_t *f, H5O_t *oh, size_t *size_ptr)
+{
+ unsigned u;
+ size_t size;
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_compute_size, FAIL);
+
+ /* check args */
+ HDassert(f);
+ HDassert(oh);
+ HDassert(size_ptr);
+
+ size = H5O_SIZEOF_HDR(f);
+
+ for (u = 0; u < oh->nchunks; u++)
+ {
+ size += oh->chunk[u].size;
+ }
+
+ HDassert(size >= H5O_SIZEOF_HDR(f));
+
+ *size_ptr = size;
+
+done:
+
+ FUNC_LEAVE_NOAPI(ret_value);
+
+} /* H5O_compute_size() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_reset
*
* Purpose: Some message data structures have internal fields that