summaryrefslogtreecommitdiffstats
path: root/src/H5Bcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Bcache.c')
-rw-r--r--src/H5Bcache.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/src/H5Bcache.c b/src/H5Bcache.c
index 0424134..dc60f9d 100644
--- a/src/H5Bcache.c
+++ b/src/H5Bcache.c
@@ -39,14 +39,17 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5MFprivate.h" /* File memory management */
+
/****************/
/* Local Macros */
/****************/
+
/******************/
/* Local Typedefs */
/******************/
+
/********************/
/* Local Prototypes */
/********************/
@@ -60,6 +63,7 @@ static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
static herr_t H5B_clear(H5F_t *f, H5B_t *b, hbool_t destroy);
static herr_t H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr);
+
/*********************/
/* Package Variables */
/*********************/
@@ -79,14 +83,14 @@ const H5AC_class_t H5AC_BT[1] = {{
/* Local Variables */
/*******************/
+
/*-------------------------------------------------------------------------
* Function: H5B_serialize
*
* Purpose: Serialize the data structure for writing to disk.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: Non-negative on success/Negative on failure
*
* Programmer: Bill Wendling
* wendling@ncsa.uiuc.edu
@@ -159,7 +163,6 @@ done:
* Purpose: Loads a B-tree node from the disk.
*
* Return: Success: Pointer to a new B-tree node.
- *
* Failure: NULL
*
* Programmer: Robb Matzke
@@ -173,13 +176,13 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
{
const H5B_class_t *type = (const H5B_class_t *) _type;
H5B_t *bt = NULL;
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
- uint8_t *p; /* Pointer into raw data buffer */
- uint8_t *native; /* Pointer to native keys */
- unsigned u; /* Local index variable */
- H5B_t *ret_value;
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ const uint8_t *p; /* Pointer into raw data buffer */
+ uint8_t *native; /* Pointer to native keys */
+ unsigned u; /* Local index variable */
+ H5B_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5B_load, NULL)
+ FUNC_ENTER_NOAPI_NOINIT(H5B_load)
/* Check arguments */
HDassert(f);
@@ -188,19 +191,24 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
HDassert(type->get_shared);
if(NULL == (bt = H5FL_MALLOC(H5B_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemset(&bt->cache_info,0,sizeof(H5AC_info_t));
- if(NULL == (bt->rc_shared=(type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't retrieve B-tree node buffer")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate B-tree struct")
+ HDmemset(&bt->cache_info, 0, sizeof(H5AC_info_t));
+
+ if(NULL == (bt->rc_shared = (type->get_shared)(f, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't retrieve B-tree node buffer")
shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
- if(NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) ||
- NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- if(H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page)<0)
+ /* Allocate space for the native keys and child addresses */
+ if(NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate buffer for native keys")
+ if(NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate buffer for child addresses")
+
+ if(H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree node")
+ /* Set the pointer into the raw data buffer */
p = shared->page;
/* magic number */
@@ -246,6 +254,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
done:
if(!ret_value && bt)
(void)H5B_dest(f, bt);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B_load() */ /*lint !e818 Can't make udata a pointer to const */
@@ -255,18 +264,12 @@ done:
*
* Purpose: Flushes a dirty B-tree node to disk.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Jun 23 1997
*
- * Changes: JRM -- 8/21/06
- * Added the flags_ptr parameter. This parameter exists to
- * allow the flush routine to report to the cache if the
- * entry is resized or renamed as a result of the flush.
- * *flags_ptr is set to H5C_CALLBACK__NO_FLAGS_SET on entry.
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -275,13 +278,13 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, uns
H5B_shared_t *shared; /* Pointer to shared B-tree info */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5B_flush, FAIL)
+ FUNC_ENTER_NOAPI_NOINIT(H5B_flush)
/* check arguments */
HDassert(f);
HDassert(H5F_addr_defined(addr));
HDassert(bt);
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
HDassert(shared->type);
HDassert(shared->type->encode);
@@ -302,7 +305,7 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, uns
} /* end if */
if(destroy)
- if(H5B_dest(f,bt) < 0)
+ if(H5B_dest(f, bt) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node")
done: