diff options
Diffstat (limited to 'src/H5B.c')
-rw-r--r-- | src/H5B.c | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -156,6 +156,7 @@ static H5B_t *H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *b); static herr_t H5B_dest(H5F_t *f, H5B_t *b); static herr_t H5B_clear(H5F_t *f, H5B_t *b, hbool_t destroy); +static herr_t H5B_compute_size(H5F_t *f, H5B_t *bt, size_t *size_ptr); /* H5B inherits cache-like properties from H5AC */ static const H5AC_class_t H5AC_BT[1] = {{ @@ -164,6 +165,7 @@ static const H5AC_class_t H5AC_BT[1] = {{ (H5AC_flush_func_t)H5B_flush, (H5AC_dest_func_t)H5B_dest, (H5AC_clear_func_t)H5B_clear, + (H5AC_size_func_t)H5B_compute_size, }}; /* Declare a free list to manage the page information */ @@ -630,6 +632,56 @@ done: /*------------------------------------------------------------------------- + * Function: H5B_compute_size + * + * Purpose: Compute the size in bytes of the specified instance of + * H5B_t on disk, and return it in *len_ptr. On failure, + * the value of *len_ptr is undefined. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 5/13/04 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B_compute_size(H5F_t *f, H5B_t *bt, size_t *size_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + size_t size; + + FUNC_ENTER_NOAPI(H5B_compute_size, FAIL) + + /* check arguments */ + HDassert(f); + HDassert(bt); + HDassert(bt->type); + HDassert(size_ptr); + + size = H5B_nodesize(f, bt->type, NULL, bt->sizeof_rkey); + + if ( size == 0 ) { + + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGETSIZE, FAIL, \ + "H5B_nodesize() failed"); + + } else { + + *size_ptr = size; + + } + +done: + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5B_H5B_compute_size() */ + + +/*------------------------------------------------------------------------- * Function: H5B_find * * Purpose: Locate the specified information in a B-tree and return |