summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-11-05 13:45:35 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-11-05 13:45:35 (GMT)
commit30a52dd1a26f507f240cf48a9342e5a1d6023983 (patch)
treecb52db492fdd7ec0e612c44ba544207f853f4356 /src
parent57932312606b1f4678b243c5bb6887cd878e0bf5 (diff)
downloadhdf5-30a52dd1a26f507f240cf48a9342e5a1d6023983.zip
hdf5-30a52dd1a26f507f240cf48a9342e5a1d6023983.tar.gz
hdf5-30a52dd1a26f507f240cf48a9342e5a1d6023983.tar.bz2
[svn-r17838] Description:
Further refactoring of v2 B-tree code, moving toward being able to pass a context information to a client's encode/decode callbacks. Also, clean up of other minor compiler warnings and code formatting issues. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.1 (amazon) in debug mode Mac OS X/32 10.6.1 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src')
-rw-r--r--src/H5.c12
-rw-r--r--src/H5Abtree2.c1
-rw-r--r--src/H5B.c2
-rw-r--r--src/H5B2.c701
-rw-r--r--src/H5B2dbg.c2
-rw-r--r--src/H5B2hdr.c6
-rw-r--r--src/H5B2int.c389
-rw-r--r--src/H5B2pkg.h50
-rw-r--r--src/H5B2test.c2
-rw-r--r--src/H5Dbtree.c4
-rw-r--r--src/H5Doh.c2
-rw-r--r--src/H5Glink.c2
-rw-r--r--src/H5HGdbg.c5
-rw-r--r--src/H5WB.c2
-rw-r--r--src/H5detect.c2
-rw-r--r--src/H5private.h137
-rw-r--r--src/H5trace.c2
17 files changed, 843 insertions, 478 deletions
diff --git a/src/H5.c b/src/H5.c
index 4041483..f4125e3 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -348,7 +348,7 @@ H5dont_atexit(void)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API_NOINIT_NOFS(H5dont_atexit)
+ FUNC_ENTER_API_NOINIT_NOERR_NOFS(H5dont_atexit)
H5TRACE0("e","");
if(H5_dont_atexit_g)
@@ -622,10 +622,10 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
char substr[] = H5_VERS_SUBRELEASE;
static int checked = 0; /* If we've already checked the version info */
static unsigned int disable_version_check = 0; /* Set if the version check should be disabled */
- herr_t ret_value=SUCCEED; /* Return value */
- static char *version_mismatch_warning=VERSION_MISMATCH_WARNING;
+ static const char *version_mismatch_warning = VERSION_MISMATCH_WARNING;
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API_NOINIT_NOFS(H5check_version)
+ FUNC_ENTER_API_NOINIT_NOERR_NOFS(H5check_version)
H5TRACE3("e", "IuIuIu", majnum, minnum, relnum);
/* Don't check again, if we already have */
@@ -692,7 +692,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
*/
sprintf(lib_str, "HDF5 library version: %d.%d.%d",
H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE);
- if (*substr){
+ if(*substr) {
HDstrcat(lib_str, "-");
HDstrncat(lib_str, substr, (sizeof(lib_str) - HDstrlen(lib_str)) - 1);
} /* end if */
@@ -769,7 +769,7 @@ H5close(void)
* whole library just to release it all right away. It is safe to call
* this function for an uninitialized library.
*/
- FUNC_ENTER_API_NOINIT_NOFS(H5close)
+ FUNC_ENTER_API_NOINIT_NOERR_NOFS(H5close)
H5TRACE0("e","");
H5_term_library();
diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c
index 8959b4c..7d0bb4c 100644
--- a/src/H5Abtree2.c
+++ b/src/H5Abtree2.c
@@ -90,7 +90,6 @@ static herr_t H5A_dense_btree2_corder_debug(FILE *stream, const H5F_t *f, hid_t
/* v2 B-tree driver callbacks for 'name' index */
static herr_t H5A_dense_btree2_name_store(void *native, const void *udata);
-static herr_t H5A_dense_btree2_name_retrieve(void *udata, const void *native);
static herr_t H5A_dense_btree2_name_compare(const void *rec1, const void *rec2);
static herr_t H5A_dense_btree2_name_encode(const H5F_t *f, uint8_t *raw,
const void *native);
diff --git a/src/H5B.c b/src/H5B.c
index aba62b0..326d675 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -1286,7 +1286,7 @@ H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
{
herr_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5B_iterate, FAIL)
+ FUNC_ENTER_NOAPI_NOERR(H5B_iterate, -)
/*
* Check arguments.
diff --git a/src/H5B2.c b/src/H5B2.c
index a30a6e2..1bdfe2a 100644
--- a/src/H5B2.c
+++ b/src/H5B2.c
@@ -64,6 +64,24 @@
static H5B2_t *H5B2_open(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls,
haddr_t addr);
static herr_t H5B2_close(H5B2_t *bt2, hid_t dxpl_id);
+static herr_t H5B2_insert_2(H5B2_t *bt2, hid_t dxpl_id, void *udata);
+static herr_t H5B2_iterate_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_operator_t op,
+ void *op_data);
+static htri_t H5B2_find_2(H5B2_t *bt2, hid_t dxpl_id, void *udata,
+ H5B2_found_t op, void *op_data);
+static herr_t H5B2_index_2(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order,
+ hsize_t idx, H5B2_found_t op, void *op_data);
+static herr_t H5B2_remove_2(H5B2_t *b2, hid_t dxpl_id, void *udata,
+ H5B2_remove_t op, void *op_data);
+static herr_t H5B2_remove_by_idx_2(H5B2_t *bt2, hid_t dxpl_id,
+ H5_iter_order_t order, hsize_t idx, H5B2_remove_t op, void *op_data);
+static herr_t H5B2_get_nrec_2(const H5B2_t *bt2, hsize_t *nrec);
+static herr_t H5B2_neighbor_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_compare_t range,
+ void *udata, H5B2_found_t op, void *op_data);
+static herr_t H5B2_modify_2(H5B2_t *bt2, hid_t dxpl_id, void *udata,
+ H5B2_modify_t op, void *op_data);
+static herr_t H5B2_iterate_size_2(H5B2_t *bt2, hid_t dxpl_id,
+ hsize_t *btree_size);
/*********************/
@@ -194,7 +212,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5B2_insert
+ * Function: H5B2_insert_2
*
* Purpose: Adds a new record to the B-tree.
*
@@ -206,24 +224,17 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
- void *udata)
+static herr_t
+H5B2_insert_2(H5B2_t *bt2, hid_t dxpl_id, void *udata)
{
- H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5B2_insert, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_insert_2, FAIL)
/* Check arguments. */
- HDassert(f);
- HDassert(cls);
- HDassert(H5F_addr_defined(addr));
-
- /* Open the B-tree */
- if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
+ HDassert(bt2);
+ HDassert(udata);
/* Set the shared v2 B-tree header's file context for this operation */
bt2->hdr->f = bt2->f;
@@ -234,23 +245,23 @@ H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
/* Check if the root node is allocated yet */
if(!H5F_addr_defined(hdr->root.addr)) {
/* Create root node as leaf node in B-tree */
- if(H5B2_create_leaf(f, dxpl_id, hdr, &(hdr->root)) < 0)
+ if(H5B2_create_leaf(hdr, dxpl_id, &(hdr->root)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node")
} /* end if */
/* Check if we need to split the root node (equiv. to a 1->2 node split) */
else if(hdr->root.node_nrec == hdr->node_info[hdr->depth].split_nrec) {
/* Split root node */
- if(H5B2_split_root(f, dxpl_id, hdr) < 0)
+ if(H5B2_split_root(hdr, dxpl_id) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split root node")
} /* end if */
/* Attempt to insert record into B-tree */
if(hdr->depth > 0) {
- if(H5B2_insert_internal(f, dxpl_id, hdr, hdr->depth, NULL, &hdr->root, udata) < 0)
+ if(H5B2_insert_internal(hdr, dxpl_id, hdr->depth, NULL, &hdr->root, udata) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node")
} /* end if */
else {
- if(H5B2_insert_leaf(f, dxpl_id, hdr, &hdr->root, udata) < 0)
+ if(H5B2_insert_leaf(hdr, dxpl_id, &hdr->root, udata) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node")
} /* end else */
@@ -259,6 +270,46 @@ H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty")
done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_insert_2() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_insert
+ *
+ * Purpose: Adds a new record to the B-tree.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 2 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
+ void *udata)
+{
+ H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B2_insert, FAIL)
+
+ /* Check arguments. */
+ HDassert(f);
+ HDassert(cls);
+ HDassert(H5F_addr_defined(addr));
+
+ /* Open the B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
+
+ /* Insert the new record */
+ if(H5B2_insert_2(bt2, dxpl_id, udata) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree")
+
+done:
/* Close the B-tree */
if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, FAIL, "unable to close B-tree")
@@ -268,6 +319,52 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B2_iterate_2
+ *
+ * Purpose: Iterate over all the records in the B-tree, in "in-order"
+ * order, making a callback for each record.
+ *
+ * If the callback returns non-zero, the iteration breaks out
+ * without finishing all the records.
+ *
+ * Return: Value from callback: non-negative on success, negative on error
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 11 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5B2_iterate_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_operator_t op, void *op_data)
+{
+ H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOERR(H5B2_iterate_2, -)
+
+ /* Check arguments. */
+ HDassert(bt2);
+ HDassert(op);
+
+ /* Set the shared v2 B-tree header's file context for this operation */
+ bt2->hdr->f = bt2->f;
+
+ /* Get the v2 B-tree header */
+ hdr = bt2->hdr;
+
+ /* Iterate through records */
+ if(hdr->root.node_nrec > 0) {
+ /* Iterate through nodes */
+ if((ret_value = H5B2_iterate_node(hdr, dxpl_id, hdr->depth, &hdr->root, op, op_data)) < 0)
+ HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed");
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_iterate_2() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B2_iterate
*
* Purpose: Iterate over all the records in the B-tree, in "in-order"
@@ -289,7 +386,6 @@ H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
H5B2_operator_t op, void *op_data)
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
- H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5B2_iterate, FAIL)
@@ -304,18 +400,9 @@ H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
- /* Set the shared v2 B-tree header's file context for this operation */
- bt2->hdr->f = bt2->f;
-
- /* Get the v2 B-tree header */
- hdr = bt2->hdr;
-
/* Iterate through records */
- if(hdr->root.node_nrec > 0) {
- /* Iterate through nodes */
- if((ret_value = H5B2_iterate_node(f, dxpl_id, hdr, hdr->depth, &hdr->root, op, op_data)) < 0)
- HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed");
- } /* end if */
+ if((ret_value = H5B2_iterate_2(bt2, dxpl_id, op, op_data)) < 0)
+ HERROR(H5E_BTREE, H5E_CANTLIST, "B-tree iteration failed");
done:
/* Close the B-tree */
@@ -327,7 +414,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5B2_find
+ * Function: H5B2_find_2
*
* Purpose: Locate the specified information in a B-tree and return
* that information by calling the provided 'OP' routine with an
@@ -349,11 +436,10 @@ done:
*
*-------------------------------------------------------------------------
*/
-htri_t
-H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
- void *udata, H5B2_found_t op, void *op_data)
+static htri_t
+H5B2_find_2(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op,
+ void *op_data)
{
- H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */
unsigned depth; /* Current depth of the tree */
@@ -361,16 +447,10 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
unsigned idx; /* Location of record which matches key */
htri_t ret_value = TRUE; /* Return value */
- FUNC_ENTER_NOAPI(H5B2_find, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_find_2, FAIL)
/* Check arguments. */
- HDassert(f);
- HDassert(cls);
- HDassert(H5F_addr_defined(addr));
-
- /* Open the B-tree */
- if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
+ HDassert(bt2);
/* Set the shared v2 B-tree header's file context for this operation */
bt2->hdr->f = bt2->f;
@@ -395,7 +475,7 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */
/* Lock B-tree current node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate node pointer for child */
@@ -408,7 +488,7 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
next_node_ptr=internal->node_ptrs[idx];
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Set pointer to next node to load */
@@ -418,14 +498,14 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
/* Make callback for current record */
if(op && (op)(H5B2_INT_NREC(internal, hdr, idx), op_data) < 0) {
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation")
} /* end if */
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Indicate record found */
@@ -440,7 +520,7 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */
/* Lock B-tree leaf node */
- if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), hdr, H5AC_READ)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), hdr, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate record */
@@ -448,7 +528,7 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
if(cmp != 0) {
/* Unlock leaf node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Record not found */
@@ -458,7 +538,7 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
/* Make callback for current record */
if(op && (op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) {
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation")
@@ -466,11 +546,61 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
} /* end else */
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
} /* end block */
done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_find_2() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_find
+ *
+ * Purpose: Locate the specified information in a B-tree and return
+ * that information by calling the provided 'OP' routine with an
+ * OP_DATA pointer. The UDATA parameter points to data passed
+ * to the key comparison function.
+ *
+ * The 'OP' routine is called with the record found and the
+ * OP_DATA pointer, to allow caller to return information about
+ * the record.
+ *
+ * If 'OP' is NULL, then this routine just returns "TRUE" when
+ * a record is present in the B-tree.
+ *
+ * Return: Non-negative (TRUE/FALSE) on success, negative on failure.
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 23 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
+ void *udata, H5B2_found_t op, void *op_data)
+{
+ H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
+ htri_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B2_find, FAIL)
+
+ /* Check arguments. */
+ HDassert(f);
+ HDassert(cls);
+ HDassert(H5F_addr_defined(addr));
+
+ /* Open the B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
+
+ /* Operate on record */
+ if((ret_value = H5B2_find_2(bt2, dxpl_id, udata, op, op_data)) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree find operation failed")
+
+done:
/* Close the B-tree */
if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, FAIL, "unable to close B-tree")
@@ -480,7 +610,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5B2_index
+ * Function: H5B2_index_2
*
* Purpose: Locate the IDX'th record in a B-tree according to the
* ordering used by the B-tree. The IDX values are 0-based.
@@ -497,28 +627,21 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
- H5_iter_order_t order, hsize_t idx, H5B2_found_t op, void *op_data)
+static herr_t
+H5B2_index_2(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order, hsize_t idx,
+ H5B2_found_t op, void *op_data)
{
- H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */
unsigned depth; /* Current depth of the tree */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5B2_index, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_index_2, FAIL)
/* Check arguments. */
- HDassert(f);
- HDassert(cls);
- HDassert(H5F_addr_defined(addr));
+ HDassert(bt2);
HDassert(op);
- /* Open the B-tree */
- if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
-
/* Set the shared v2 B-tree header's file context for this operation */
bt2->hdr->f = bt2->f;
@@ -550,7 +673,7 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
unsigned u; /* Local index variable */
/* Lock B-tree current node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Search for record with correct index */
@@ -561,7 +684,7 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
next_node_ptr = internal->node_ptrs[u];
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Set pointer to next node to load */
@@ -576,14 +699,14 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
/* Make callback for current record */
if((op)(H5B2_INT_NREC(internal, hdr, u), op_data) < 0) {
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation")
} /* end if */
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_DONE(SUCCEED);
@@ -603,7 +726,7 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
next_node_ptr = internal->node_ptrs[u];
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Set pointer to next node to load */
@@ -622,7 +745,7 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */
/* Lock B-tree leaf node */
- if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), hdr, H5AC_READ)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), hdr, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Sanity check index */
@@ -631,58 +754,97 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
/* Make callback for correct record */
if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) {
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation")
} /* end if */
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
} /* end block */
done:
- /* Close the B-tree */
- if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, FAIL, "unable to close B-tree")
-
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B2_index() */
+} /* H5B2_index_2() */
/*-------------------------------------------------------------------------
- * Function: H5B2_remove
+ * Function: H5B2_index
*
- * Purpose: Removes a record from a B-tree.
+ * Purpose: Locate the IDX'th record in a B-tree according to the
+ * ordering used by the B-tree. The IDX values are 0-based.
*
- * Return: Non-negative on success/Negative on failure
+ * The 'OP' routine is called with the record found and the
+ * OP_DATA pointer, to allow caller to return information about
+ * the record.
+ *
+ * Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
- * Feb 25 2005
+ * Feb 23 2005
*
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
- void *udata, H5B2_remove_t op, void *op_data)
+H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
+ H5_iter_order_t order, hsize_t idx, H5B2_found_t op, void *op_data)
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
- H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5B2_remove, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_index, FAIL)
/* Check arguments. */
HDassert(f);
HDassert(cls);
HDassert(H5F_addr_defined(addr));
+ HDassert(op);
/* Open the B-tree */
if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
+ /* Locate and operate on record */
+ if(H5B2_index_2(bt2, dxpl_id, order, idx, op, op_data) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree index operation failed")
+
+done:
+ /* Close the B-tree */
+ if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, FAIL, "unable to close B-tree")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_index() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_remove_2
+ *
+ * Purpose: Removes a record from a B-tree.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 25 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5B2_remove_2(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_remove_t op,
+ void *op_data)
+{
+ H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B2_remove_2, FAIL)
+
+ /* Check arguments. */
+ HDassert(bt2);
+
/* Set the shared v2 B-tree header's file context for this operation */
bt2->hdr->f = bt2->f;
@@ -697,7 +859,7 @@ H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
if(hdr->depth > 0) {
hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */
- if(H5B2_remove_internal(f, dxpl_id, hdr, &depth_decreased, NULL, hdr->depth,
+ if(H5B2_remove_internal(hdr, dxpl_id, &depth_decreased, NULL, hdr->depth,
&(hdr->cache_info), NULL, &hdr->root, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node")
@@ -715,7 +877,7 @@ H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
} /* end for */
} /* end if */
else {
- if(H5B2_remove_leaf(f, dxpl_id, hdr, &hdr->root, udata, op, op_data) < 0)
+ if(H5B2_remove_leaf(hdr, dxpl_id, &hdr->root, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node")
} /* end else */
@@ -727,37 +889,31 @@ H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty")
done:
- /* Close the B-tree */
- if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, FAIL, "unable to close B-tree")
-
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B2_remove() */
+} /* H5B2_remove_2() */
/*-------------------------------------------------------------------------
- * Function: H5B2_remove_by_idx
+ * Function: H5B2_remove
*
- * Purpose: Removes the n'th record from a B-tree.
+ * Purpose: Removes a record from a B-tree.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Nov 14 2006
+ * koziol@ncsa.uiuc.edu
+ * Feb 25 2005
*
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls,
- haddr_t addr, H5_iter_order_t order, hsize_t idx, H5B2_remove_t op,
- void *op_data)
+H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
+ void *udata, H5B2_remove_t op, void *op_data)
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
- H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5B2_remove_by_idx, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_remove, FAIL)
/* Check arguments. */
HDassert(f);
@@ -768,6 +924,44 @@ H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls,
if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
+ /* Attempt to remove record from B-tree */
+ if(H5B2_remove_2(bt2, dxpl_id, udata, op, op_data) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree")
+
+done:
+ /* Close the B-tree */
+ if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, FAIL, "unable to close B-tree")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_remove() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_remove_by_idx_2
+ *
+ * Purpose: Removes the n'th record from a B-tree.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Nov 14 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5B2_remove_by_idx_2(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order,
+ hsize_t idx, H5B2_remove_t op, void *op_data)
+{
+ H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B2_remove_by_idx_2, FAIL)
+
+ /* Check arguments. */
+ HDassert(bt2);
+
/* Set the shared v2 B-tree header's file context for this operation */
bt2->hdr->f = bt2->f;
@@ -790,7 +984,7 @@ H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls,
if(hdr->depth > 0) {
hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */
- if(H5B2_remove_internal_by_idx(f, dxpl_id, hdr, &depth_decreased, NULL, hdr->depth,
+ if(H5B2_remove_internal_by_idx(hdr, dxpl_id, &depth_decreased, NULL, hdr->depth,
&(hdr->cache_info), NULL, &hdr->root, idx, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node")
@@ -808,7 +1002,7 @@ H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls,
} /* end for */
} /* end if */
else {
- if(H5B2_remove_leaf_by_idx(f, dxpl_id, hdr, &hdr->root, (unsigned)idx, op, op_data) < 0)
+ if(H5B2_remove_leaf_by_idx(hdr, dxpl_id, &hdr->root, (unsigned)idx, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node")
} /* end else */
@@ -820,6 +1014,47 @@ H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls,
HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty")
done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_remove_by_idx_2() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_remove_by_idx
+ *
+ * Purpose: Removes the n'th record from a B-tree.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Nov 14 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls,
+ haddr_t addr, H5_iter_order_t order, hsize_t idx, H5B2_remove_t op,
+ void *op_data)
+{
+ H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B2_remove_by_idx, FAIL)
+
+ /* Check arguments. */
+ HDassert(f);
+ HDassert(cls);
+ HDassert(H5F_addr_defined(addr));
+
+ /* Open the B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
+
+ /* Attempt to remove record from B-tree */
+ if(H5B2_remove_by_idx_2(bt2, dxpl_id, order, idx, op, op_data) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree")
+
+done:
/* Close the B-tree */
if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, FAIL, "unable to close B-tree")
@@ -829,6 +1064,35 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B2_get_nrec_2
+ *
+ * Purpose: Retrieves the number of records in a B-tree
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 25 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5B2_get_nrec_2(const H5B2_t *bt2, hsize_t *nrec)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_get_nrec_2)
+
+ /* Check arguments. */
+ HDassert(bt2);
+ HDassert(nrec);
+
+ /* Get B-tree number of records */
+ *nrec = bt2->hdr->root.all_nrec;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* H5B2_get_nrec_2() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B2_get_nrec
*
* Purpose: Retrieves the number of records in a B-tree
@@ -846,7 +1110,6 @@ H5B2_get_nrec(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
hsize_t *nrec)
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
- H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5B2_get_nrec, FAIL)
@@ -861,14 +1124,9 @@ H5B2_get_nrec(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
- /* Set the shared v2 B-tree header's file context for this operation */
- bt2->hdr->f = bt2->f;
-
- /* Get the v2 B-tree header */
- hdr = bt2->hdr;
-
- /* Get B-tree number of records */
- *nrec = hdr->root.all_nrec;
+ /* Get the number of records in the B-tree */
+ if(H5B2_get_nrec_2(bt2, nrec) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to get # of records in B-tree")
done:
/* Close the B-tree */
@@ -880,7 +1138,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5B2_neighbor
+ * Function: H5B2_neighbor_2
*
* Purpose: Locate a record relative to the specified information in a
* B-tree and return that information by filling in fields of the
@@ -904,26 +1162,19 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5B2_neighbor(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
- H5B2_compare_t range, void *udata, H5B2_found_t op, void *op_data)
+static herr_t
+H5B2_neighbor_2(H5B2_t *bt2, hid_t dxpl_id, H5B2_compare_t range, void *udata,
+ H5B2_found_t op, void *op_data)
{
- H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5B2_neighbor, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_neighbor_2, FAIL)
/* Check arguments. */
- HDassert(f);
- HDassert(cls);
- HDassert(H5F_addr_defined(addr));
+ HDassert(bt2);
HDassert(op);
- /* Open the B-tree */
- if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
-
/* Set the shared v2 B-tree header's file context for this operation */
bt2->hdr->f = bt2->f;
@@ -936,15 +1187,68 @@ H5B2_neighbor(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
/* Attempt to find neighbor record in B-tree */
if(hdr->depth > 0) {
- if(H5B2_neighbor_internal(f, dxpl_id, hdr, hdr->depth, &hdr->root, NULL, range, udata, op, op_data) < 0)
+ if(H5B2_neighbor_internal(hdr, dxpl_id, hdr->depth, &hdr->root, NULL, range, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree internal node")
} /* end if */
else {
- if(H5B2_neighbor_leaf(f, dxpl_id, hdr, &hdr->root, NULL, range, udata, op, op_data) < 0)
+ if(H5B2_neighbor_leaf(hdr, dxpl_id, &hdr->root, NULL, range, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree leaf node")
} /* end else */
done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_neighbor_2() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_neighbor
+ *
+ * Purpose: Locate a record relative to the specified information in a
+ * B-tree and return that information by filling in fields of the
+ * caller-supplied UDATA pointer depending on the type of leaf node
+ * requested. The UDATA can point to additional data passed
+ * to the key comparison function.
+ *
+ * The 'OP' routine is called with the record found and the
+ * OP_DATA pointer, to allow caller to return information about
+ * the record.
+ *
+ * The RANGE indicates whether to search for records less than or
+ * equal to, or greater than or equal to the information passed
+ * in with UDATA.
+ *
+ * Return: Non-negative on success, negative on failure.
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Mar 8 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_neighbor(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
+ H5B2_compare_t range, void *udata, H5B2_found_t op, void *op_data)
+{
+ H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B2_neighbor, FAIL)
+
+ /* Check arguments. */
+ HDassert(f);
+ HDassert(cls);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(op);
+
+ /* Open the B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
+
+ /* Attempt to find neighbor record in B-tree */
+ if(H5B2_neighbor_2(bt2, dxpl_id, range, udata, op, op_data) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree")
+
+done:
/* Close the B-tree */
if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, FAIL, "unable to close B-tree")
@@ -954,7 +1258,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5B2_modify
+ * Function: H5B2_modify_2
*
* Purpose: Locate the specified information in a B-tree and modify it.
* The UDATA points to additional data passed
@@ -973,11 +1277,10 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
- void *udata, H5B2_modify_t op, void *op_data)
+static herr_t
+H5B2_modify_2(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op,
+ void *op_data)
{
- H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */
unsigned depth; /* Current depth of the tree */
@@ -985,18 +1288,12 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
unsigned idx; /* Location of record which matches key */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5B2_modify, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_modify_2, FAIL)
/* Check arguments. */
- HDassert(f);
- HDassert(cls);
- HDassert(H5F_addr_defined(addr));
+ HDassert(bt2);
HDassert(op);
- /* Open the B-tree */
- if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
-
/* Set the shared v2 B-tree header's file context for this operation */
bt2->hdr->f = bt2->f;
@@ -1021,7 +1318,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */
/* Lock B-tree current node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_WRITE)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate node pointer for child */
@@ -1034,7 +1331,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
next_node_ptr = internal->node_ptrs[idx];
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Set pointer to next node to load */
@@ -1049,7 +1346,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
HDassert(changed == FALSE);
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree find operation")
@@ -1059,7 +1356,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
internal_flags |= changed ? H5AC__DIRTIED_FLAG : 0;
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, internal_flags) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, internal_flags) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_DONE(SUCCEED);
@@ -1075,7 +1372,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
hbool_t changed = FALSE;/* Whether the 'modify' callback changed the record */
/* Lock B-tree leaf node */
- if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate record */
@@ -1083,7 +1380,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
if(cmp != 0) {
/* Unlock leaf node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Note: don't push error on stack, leave that to next higher level,
@@ -1103,7 +1400,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
HDassert(changed == FALSE);
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree find operation")
@@ -1114,11 +1411,59 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
leaf_flags |= (changed ? H5AC__DIRTIED_FLAG : 0);
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
}
done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_modify_2() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_modify
+ *
+ * Purpose: Locate the specified information in a B-tree and modify it.
+ * The UDATA points to additional data passed
+ * to the key comparison function for locating the record to
+ * modify.
+ *
+ * The 'OP' routine is called with the record found and the
+ * OP_DATA pointer, to allow caller to modify information about
+ * the record.
+ *
+ * Return: Non-negative on success, negative on failure.
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Mar 10 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr,
+ void *udata, H5B2_modify_t op, void *op_data)
+{
+ H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B2_modify, FAIL)
+
+ /* Check arguments. */
+ HDassert(f);
+ HDassert(cls);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(op);
+
+ /* Open the B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
+
+ /* Locate & modify record */
+ if(H5B2_modify_2(bt2, dxpl_id, udata, op, op_data) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree")
+
+done:
/* Close the B-tree */
if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, FAIL, "unable to close B-tree")
@@ -1128,7 +1473,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5B2_iterate_size
+ * Function: H5B2_iterate_size_2
*
* Purpose: Iterate over all the records in the B-tree, collecting
* storage info.
@@ -1140,25 +1485,18 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr, hsize_t *btree_size)
+static herr_t
+H5B2_iterate_size_2(H5B2_t *bt2, hid_t dxpl_id, hsize_t *btree_size)
{
- H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
H5B2_hdr_t *hdr; /* Pointer to the B-tree header */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5B2_iterate_size, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_iterate_size_2, FAIL)
/* Check arguments. */
- HDassert(f);
- HDassert(cls);
- HDassert(H5F_addr_defined(addr));
+ HDassert(bt2);
HDassert(btree_size);
- /* Open the B-tree */
- if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
-
/* Set the shared v2 B-tree header's file context for this operation */
bt2->hdr->f = bt2->f;
@@ -1166,7 +1504,7 @@ H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr
hdr = bt2->hdr;
/* Add size of header to B-tree metadata total */
- *btree_size += H5B2_HEADER_SIZE(f);
+ *btree_size += H5B2_HEADER_SIZE(hdr->f);
/* Iterate through records */
if(hdr->root.node_nrec > 0) {
@@ -1175,11 +1513,52 @@ H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls, haddr_t addr
*btree_size += hdr->node_size;
else
/* Iterate through nodes */
- if(H5B2_iterate_size_node(f, dxpl_id, hdr, hdr->depth, &hdr->root, btree_size) < 0)
+ if(H5B2_iterate_size_node(hdr, dxpl_id, hdr->depth, &hdr->root, btree_size) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed")
} /* end if */
done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_iterate_size_2() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_iterate_size
+ *
+ * Purpose: Iterate over all the records in the B-tree, collecting
+ * storage info.
+ *
+ * Return: non-negative on success, negative on error
+ *
+ * Programmer: Vailin Choi
+ * June 19 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls,
+ haddr_t addr, hsize_t *btree_size)
+{
+ H5B2_t *bt2 = NULL; /* Pointer to the B-tree */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B2_iterate_size, FAIL)
+
+ /* Check arguments. */
+ HDassert(f);
+ HDassert(cls);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(btree_size);
+
+ /* Open the B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl_id, cls, addr)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, FAIL, "unable to open B-tree")
+
+ /* Iterate through B-tree, collective size info */
+ if(H5B2_iterate_size_2(bt2, dxpl_id, btree_size) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't get size information for B-tree")
+
+done:
/* Close the B-tree */
if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, FAIL, "unable to close B-tree")
diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c
index 86877a6..db469f2 100644
--- a/src/H5B2dbg.c
+++ b/src/H5B2dbg.c
@@ -221,7 +221,7 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
/*
* Load the B-tree internal node
*/
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, addr, nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, addr, nrec, depth, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree internal node")
/* Print opening message */
diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c
index 95bafdd..31e1674 100644
--- a/src/H5B2hdr.c
+++ b/src/H5B2hdr.c
@@ -188,7 +188,7 @@ HDmemset(hdr->page, 0, hdr->node_size);
/* Initialize internal node info */
if(depth > 0) {
for(u = 1; u < (depth + 1); u++) {
- sz_max_nrec = H5B2_NUM_INT_REC(f, hdr, u);
+ sz_max_nrec = H5B2_NUM_INT_REC(hdr, u);
H5_ASSIGN_OVERFLOW(/* To: */ hdr->node_info[u].max_nrec, /* From: */ sz_max_nrec, /* From: */ size_t, /* To: */ unsigned)
HDassert(hdr->node_info[u].max_nrec <= hdr->node_info[u - 1].max_nrec);
@@ -248,6 +248,8 @@ H5B2_hdr_alloc(H5F_t *f)
/* Assign non-zero information */
hdr->f = f;
+ hdr->sizeof_addr = H5F_SIZEOF_ADDR(f);
+ hdr->sizeof_size = H5F_SIZEOF_SIZE(f);
hdr->root.addr = HADDR_UNDEF;
/* Set return value */
@@ -579,7 +581,7 @@ H5B2_hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id)
/* Delete all nodes in B-tree */
if(H5F_addr_defined(hdr->root.addr))
- if(H5B2_delete_node(hdr->f, dxpl_id, hdr, hdr->depth, &hdr->root, hdr->remove_op, hdr->remove_op_data) < 0)
+ if(H5B2_delete_node(hdr, dxpl_id, hdr->depth, &hdr->root, hdr->remove_op, hdr->remove_op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to delete B-tree nodes")
/* Indicate that the heap header should be deleted & file space freed */
diff --git a/src/H5B2int.c b/src/H5B2int.c
index 33fa63b..3d37949 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -61,22 +61,22 @@
/********************/
/* Helper functions */
-static herr_t H5B2_create_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+static herr_t H5B2_create_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *node_ptr, unsigned depth);
-static herr_t H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth,
+static herr_t H5B2_split1(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_node_ptr_t *curr_node_ptr, unsigned *parent_cache_info_flags_ptr,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx);
-static herr_t H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth,
+static herr_t H5B2_redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *internal, unsigned idx);
-static herr_t H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
+static herr_t H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx);
-static herr_t H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
+static herr_t H5B2_merge2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_node_ptr_t *curr_node_ptr, unsigned *parent_cache_info_flags_ptr,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx);
-static herr_t H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
+static herr_t H5B2_merge3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_node_ptr_t *curr_node_ptr, unsigned *parent_cache_info_flags_ptr,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx);
-static herr_t H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth,
+static herr_t H5B2_swap_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *internal, unsigned *internal_flags_ptr,
unsigned idx, void *swap_loc);
#ifdef H5B2_DEBUG
@@ -172,12 +172,11 @@ H5B2_locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off,
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_ptr,
+H5B2_split1(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_ptr,
unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal,
unsigned *internal_flags_ptr, unsigned idx)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
- H5B2_hdr_t *hdr; /* Pointer to B-tree header */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
void *left_child, *right_child; /* Pointers to child nodes */
unsigned *left_nrec, *right_nrec; /* Pointers to child # of records */
@@ -189,14 +188,11 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
FUNC_ENTER_NOAPI_NOINIT(H5B2_split1)
- HDassert(f);
+ /* Check arguments. */
+ HDassert(hdr);
HDassert(internal);
HDassert(internal_flags_ptr);
- /* Get the pointer to the B-tree header info */
- hdr = internal->hdr;
- HDassert(hdr);
-
/* Slide records in parent node up one space, to make room for promoted record */
if(idx < internal->nrec) {
HDmemmove(H5B2_INT_NREC(internal, hdr, idx + 1), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size * (internal->nrec - idx));
@@ -209,7 +205,7 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
/* Create new internal node */
internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec = 0;
- if(H5B2_create_internal(f, dxpl_id, hdr, &(internal->node_ptrs[idx + 1]), (depth - 1)) < 0)
+ if(H5B2_create_internal(hdr, dxpl_id, &(internal->node_ptrs[idx + 1]), (depth - 1)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new internal node")
/* Setup information for unlocking child nodes */
@@ -218,9 +214,9 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
right_addr = internal->node_ptrs[idx + 1].addr;
/* Protect both leafs */
- if(NULL == (left_int = H5B2_protect_internal(f, dxpl_id, hdr, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (left_int = H5B2_protect_internal(hdr, dxpl_id, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
- if(NULL == (right_int = H5B2_protect_internal(f, dxpl_id, hdr, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (right_int = H5B2_protect_internal(hdr, dxpl_id, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* More setup for child nodes */
@@ -238,7 +234,7 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
/* Create new leaf node */
internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec = 0;
- if(H5B2_create_leaf(f, dxpl_id, hdr, &(internal->node_ptrs[idx + 1])) < 0)
+ if(H5B2_create_leaf(hdr, dxpl_id, &(internal->node_ptrs[idx + 1])) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new leaf node")
/* Setup information for unlocking child nodes */
@@ -247,9 +243,9 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
right_addr = internal->node_ptrs[idx + 1].addr;
/* Protect both leafs */
- if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
- if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for child nodes */
@@ -333,9 +329,9 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
#endif /* H5B2_DEBUG */
/* Release child nodes (marked as dirty) */
- if(H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node")
- if(H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node")
done:
@@ -358,7 +354,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr)
+H5B2_split_root(H5B2_hdr_t *hdr, hid_t dxpl_id)
{
H5B2_internal_t *new_root; /* Pointer to new root node */
unsigned new_root_flags = H5AC__NO_FLAGS_SET; /* Cache flags for new root node */
@@ -369,7 +365,7 @@ H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr)
FUNC_ENTER_NOAPI_NOINIT(H5B2_split_root)
- HDassert(f);
+ /* Check arguments. */
HDassert(hdr);
/* Update depth of B-tree */
@@ -380,7 +376,7 @@ H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Update node info for new depth of tree */
- sz_max_nrec = H5B2_NUM_INT_REC(f, hdr, hdr->depth);
+ sz_max_nrec = H5B2_NUM_INT_REC(hdr, hdr->depth);
H5_ASSIGN_OVERFLOW(/* To: */ hdr->node_info[hdr->depth].max_nrec, /* From: */ sz_max_nrec, /* From: */ size_t, /* To: */ unsigned)
hdr->node_info[hdr->depth].split_nrec = (hdr->node_info[hdr->depth].max_nrec * hdr->split_percent) / 100;
hdr->node_info[hdr->depth].merge_nrec = (hdr->node_info[hdr->depth].max_nrec * hdr->merge_percent) / 100;
@@ -398,27 +394,27 @@ H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr)
/* Create new internal node to use as root */
hdr->root.node_nrec = 0;
- if(H5B2_create_internal(f, dxpl_id, hdr, &(hdr->root), hdr->depth) < 0)
+ if(H5B2_create_internal(hdr, dxpl_id, &(hdr->root), hdr->depth) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new internal node")
/* Protect new root node */
- if(NULL == (new_root = H5B2_protect_internal(f, dxpl_id, hdr, hdr->root.addr, hdr->root.node_nrec, hdr->depth, H5AC_WRITE)))
+ if(NULL == (new_root = H5B2_protect_internal(hdr, dxpl_id, hdr->root.addr, hdr->root.node_nrec, hdr->depth, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Set first node pointer in root node to old root node pointer info */
new_root->node_ptrs[0] = old_root_ptr;
/* Split original root node */
- if(H5B2_split1(f, dxpl_id, hdr->depth, &(hdr->root), NULL, new_root, &new_root_flags, 0) < 0)
+ if(H5B2_split1(hdr, dxpl_id, hdr->depth, &(hdr->root), NULL, new_root, &new_root_flags, 0) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split old root node")
/* Release new root node (marked as dirty) */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, hdr->root.addr, new_root, new_root_flags) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, hdr->root.addr, new_root, new_root_flags) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree internal node")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_split_root */
+} /* end H5B2_split_root() */
/*-------------------------------------------------------------------------
@@ -436,10 +432,10 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *internal, unsigned idx)
+H5B2_redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
+ H5B2_internal_t *internal, unsigned idx)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
- H5B2_hdr_t *hdr; /* B-tree's header */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
void *left_child, *right_child; /* Pointers to child nodes */
unsigned *left_nrec, *right_nrec; /* Pointers to child # of records */
@@ -450,12 +446,9 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int
FUNC_ENTER_NOAPI_NOINIT(H5B2_redistribute2)
- HDassert(f);
- HDassert(internal);
-
- /* Get the pointer to the B-tree header */
- hdr = internal->hdr;
+ /* Check arguments. */
HDassert(hdr);
+ HDassert(internal);
/* Check for the kind of B-tree node to redistribute */
if(depth > 1) {
@@ -468,9 +461,9 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int
right_addr = internal->node_ptrs[idx + 1].addr;
/* Lock left & right B-tree child nodes */
- if(NULL == (left_internal = H5B2_protect_internal(f, dxpl_id, hdr, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (left_internal = H5B2_protect_internal(hdr, dxpl_id, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
- if(NULL == (right_internal = H5B2_protect_internal(f, dxpl_id, hdr, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (right_internal = H5B2_protect_internal(hdr, dxpl_id, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for child nodes */
@@ -493,9 +486,9 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int
right_addr = internal->node_ptrs[idx + 1].addr;
/* Lock left & right B-tree child nodes */
- if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
- if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for child nodes */
@@ -632,9 +625,9 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int
#endif /* H5B2_DEBUG */
/* Release child nodes (marked as dirty) */
- if(H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
- if(H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
done:
@@ -657,11 +650,10 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
+H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
- H5B2_hdr_t *hdr; /* B-tree's header */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
haddr_t middle_addr; /* Address of middle child node */
void *left_child, *right_child; /* Pointers to child nodes */
@@ -678,14 +670,11 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
FUNC_ENTER_NOAPI_NOINIT(H5B2_redistribute3)
- HDassert(f);
+ /* Check arguments. */
+ HDassert(hdr);
HDassert(internal);
HDassert(internal_flags_ptr);
- /* Get the pointer to the B-tree header */
- hdr = internal->hdr;
- HDassert(hdr);
-
/* Check for the kind of B-tree node to redistribute */
if(depth > 1) {
H5B2_internal_t *left_internal; /* Pointer to left internal node */
@@ -699,11 +688,11 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
right_addr = internal->node_ptrs[idx + 1].addr;
/* Lock B-tree child nodes */
- if(NULL == (left_internal = H5B2_protect_internal(f, dxpl_id, hdr, left_addr, internal->node_ptrs[idx - 1].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (left_internal = H5B2_protect_internal(hdr, dxpl_id, left_addr, internal->node_ptrs[idx - 1].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
- if(NULL == (middle_internal = H5B2_protect_internal(f, dxpl_id, hdr, middle_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (middle_internal = H5B2_protect_internal(hdr, dxpl_id, middle_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
- if(NULL == (right_internal = H5B2_protect_internal(f, dxpl_id, hdr, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (right_internal = H5B2_protect_internal(hdr, dxpl_id, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* More setup for child nodes */
@@ -732,11 +721,11 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
right_addr = internal->node_ptrs[idx + 1].addr;
/* Lock B-tree child nodes */
- if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx - 1].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx - 1].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
- if(NULL == (middle_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, middle_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (middle_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, middle_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
- if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for child nodes */
@@ -954,25 +943,25 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
HDfprintf(stderr, "%s: Internal records:\n", FUNC);
for(u = 0; u < internal->nrec; u++) {
HDfprintf(stderr, "%s: u = %u\n", FUNC, u);
- (hdr->cls->debug)(stderr, f, dxpl_id, 3, 4, H5B2_INT_NREC(internal, hdr, u), NULL);
+ (hdr->cls->debug)(stderr, hdr->f, dxpl_id, 3, 4, H5B2_INT_NREC(internal, hdr, u), NULL);
} /* end for */
HDfprintf(stderr, "%s: Left Child records:\n", FUNC);
for(u = 0; u < *left_nrec; u++) {
HDfprintf(stderr, "%s: u = %u\n", FUNC, u);
- (hdr->cls->debug)(stderr, f, dxpl_id, 3, 4, H5B2_NAT_NREC(left_native, hdr, u), NULL);
+ (hdr->cls->debug)(stderr, hdr->f, dxpl_id, 3, 4, H5B2_NAT_NREC(left_native, hdr, u), NULL);
} /* end for */
HDfprintf(stderr, "%s: Middle Child records:\n", FUNC);
for(u = 0; u < *middle_nrec; u++) {
HDfprintf(stderr, "%s: u = %u\n", FUNC, u);
- (hdr->cls->debug)(stderr, f, dxpl_id, 3, 4, H5B2_NAT_NREC(middle_native, hdr, u), NULL);
+ (hdr->cls->debug)(stderr, hdr->f, dxpl_id, 3, 4, H5B2_NAT_NREC(middle_native, hdr, u), NULL);
} /* end for */
HDfprintf(stderr, "%s: Right Child records:\n", FUNC);
for(u = 0; u < *right_nrec; u++) {
HDfprintf(stderr, "%s: u = %u\n", FUNC, u);
- (hdr->cls->debug)(stderr, f, dxpl_id, 3, 4, H5B2_NAT_NREC(right_native, hdr, u), NULL);
+ (hdr->cls->debug)(stderr, hdr->f, dxpl_id, 3, 4, H5B2_NAT_NREC(right_native, hdr, u), NULL);
} /* end for */
for(u = 0; u < internal->nrec + 1; u++)
@@ -1003,11 +992,11 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
#endif /* H5B2_DEBUG */
/* Unlock child nodes (marked as dirty) */
- if(H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
- if(H5AC_unprotect(f, dxpl_id, child_class, middle_addr, middle_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, middle_addr, middle_child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
- if(H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
done:
@@ -1031,12 +1020,11 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
+H5B2_merge2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_node_ptr_t *curr_node_ptr, unsigned *parent_cache_info_flags_ptr,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
- H5B2_hdr_t *hdr; /* B-tree's header */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
void *left_child, *right_child; /* Pointers to left & right child nodes */
unsigned *left_nrec, *right_nrec; /* Pointers to left & right child # of records */
@@ -1046,15 +1034,12 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
FUNC_ENTER_NOAPI_NOINIT(H5B2_merge2)
- HDassert(f);
+ /* Check arguments. */
+ HDassert(hdr);
HDassert(curr_node_ptr);
HDassert(internal);
HDassert(internal_flags_ptr);
- /* Get the pointer to the B-tree header */
- hdr = internal->hdr;
- HDassert(hdr);
-
/* Check for the kind of B-tree node to split */
if(depth > 1) {
H5B2_internal_t *left_internal; /* Pointer to left internal node */
@@ -1066,9 +1051,9 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
right_addr = internal->node_ptrs[idx + 1].addr;
/* Lock left & right B-tree child nodes */
- if(NULL == (left_internal = H5B2_protect_internal(f, dxpl_id, hdr, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (left_internal = H5B2_protect_internal(hdr, dxpl_id, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
- if(NULL == (right_internal = H5B2_protect_internal(f, dxpl_id, hdr, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (right_internal = H5B2_protect_internal(hdr, dxpl_id, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* More setup for accessing child node information */
@@ -1091,9 +1076,9 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
right_addr = internal->node_ptrs[idx + 1].addr;
/* Lock left & right B-tree child nodes */
- if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
- if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for accessing child node information */
@@ -1155,16 +1140,16 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
#endif /* H5B2_DEBUG */
/* Unlock left node (marked as dirty) */
- if(H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
/* Delete right node & remove from cache (marked as dirty) */
- if(H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_merge2 */
+} /* end H5B2_merge2() */
/*-------------------------------------------------------------------------
@@ -1183,12 +1168,11 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
+H5B2_merge3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_node_ptr_t *curr_node_ptr, unsigned *parent_cache_info_flags_ptr,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
- H5B2_hdr_t *hdr; /* B-tree's header */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
haddr_t middle_addr; /* Address of middle child node */
void *left_child, *right_child; /* Pointers to left & right child nodes */
@@ -1204,15 +1188,12 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
FUNC_ENTER_NOAPI_NOINIT(H5B2_merge3)
- HDassert(f);
+ /* Check arguments. */
+ HDassert(hdr);
HDassert(curr_node_ptr);
HDassert(internal);
HDassert(internal_flags_ptr);
- /* Get the pointer to the B-tree header */
- hdr = internal->hdr;
- HDassert(hdr);
-
/* Check for the kind of B-tree node to split */
if(depth > 1) {
H5B2_internal_t *left_internal; /* Pointer to left internal node */
@@ -1226,11 +1207,11 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
right_addr = internal->node_ptrs[idx + 1].addr;
/* Lock B-tree child nodes */
- if(NULL == (left_internal = H5B2_protect_internal(f, dxpl_id, hdr, left_addr, internal->node_ptrs[idx - 1].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (left_internal = H5B2_protect_internal(hdr, dxpl_id, left_addr, internal->node_ptrs[idx - 1].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
- if(NULL == (middle_internal = H5B2_protect_internal(f, dxpl_id, hdr, middle_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (middle_internal = H5B2_protect_internal(hdr, dxpl_id, middle_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
- if(NULL == (right_internal = H5B2_protect_internal(f, dxpl_id, hdr, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (right_internal = H5B2_protect_internal(hdr, dxpl_id, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* More setup for accessing child node information */
@@ -1259,11 +1240,11 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
right_addr = internal->node_ptrs[idx + 1].addr;
/* Lock B-tree child nodes */
- if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx - 1].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx - 1].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
- if(NULL == (middle_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, middle_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (middle_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, middle_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
- if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for accessing child node information */
@@ -1375,18 +1356,18 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
#endif /* H5B2_DEBUG */
/* Unlock left & middle nodes (marked as dirty) */
- if(H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
- if(H5AC_unprotect(f, dxpl_id, child_class, middle_addr, middle_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, middle_addr, middle_child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
/* Delete right node & remove from cache (marked as dirty) */
- if(H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_merge3 */
+} /* end H5B2_merge3() */
/*-------------------------------------------------------------------------
@@ -1405,12 +1386,11 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth,
+H5B2_swap_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *internal, unsigned *internal_flags_ptr,
unsigned idx, void *swap_loc)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
- H5B2_hdr_t *hdr; /* B-tree's header */
haddr_t child_addr; /* Address of child node */
void *child; /* Pointer to child node */
uint8_t *child_native; /* Pointer to child's native records */
@@ -1418,15 +1398,12 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth,
FUNC_ENTER_NOAPI_NOINIT(H5B2_swap_leaf)
- HDassert(f);
+ /* Check arguments. */
+ HDassert(hdr);
HDassert(internal);
HDassert(internal_flags_ptr);
HDassert(idx <= internal->nrec);
- /* Get the pointer to the B-tree header */
- hdr = internal->hdr;
- HDassert(hdr);
-
/* Check for the kind of B-tree node to swap */
if(depth > 1) {
H5B2_internal_t *child_internal; /* Pointer to internal node */
@@ -1436,7 +1413,7 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth,
child_addr = internal->node_ptrs[idx].addr;
/* Lock B-tree child nodes */
- if(NULL == (child_internal = H5B2_protect_internal(f, dxpl_id, hdr, child_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (child_internal = H5B2_protect_internal(hdr, dxpl_id, child_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* More setup for accessing child node information */
@@ -1451,7 +1428,7 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth,
child_addr = internal->node_ptrs[idx].addr;
/* Lock B-tree child node */
- if(NULL == (child_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, child_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (child_leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, child_class, child_addr, &(internal->node_ptrs[idx].node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for accessing child node information */
@@ -1476,7 +1453,7 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth,
#endif /* H5B2_DEBUG */
/* Unlock child node */
- if(H5AC_unprotect(f, dxpl_id, child_class, child_addr, child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, child_class, child_addr, child, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
done:
@@ -1498,7 +1475,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr,
+H5B2_insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr,
void *udata)
{
H5B2_leaf_t *leaf; /* Pointer to leaf node */
@@ -1509,13 +1486,12 @@ H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr
FUNC_ENTER_NOAPI_NOINIT(H5B2_insert_leaf)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(curr_node_ptr);
HDassert(H5F_addr_defined(curr_node_ptr->addr));
/* Lock current B-tree node */
- if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, &(curr_node_ptr->node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, &(curr_node_ptr->node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* Must have a leaf node with enough space to insert a record now */
@@ -1553,7 +1529,7 @@ H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr
done:
/* Release the B-tree leaf node (marked as dirty) */
- if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__DIRTIED_FLAG) < 0)
+ if(leaf && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__DIRTIED_FLAG) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1574,7 +1550,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
+H5B2_insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr,
void *udata)
{
@@ -1586,14 +1562,13 @@ H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
FUNC_ENTER_NOAPI_NOINIT(H5B2_insert_internal)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(depth > 0);
HDassert(curr_node_ptr);
HDassert(H5F_addr_defined(curr_node_ptr->addr));
/* Lock current B-tree node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC_WRITE)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Split or redistribute child node pointers, if necessary */
@@ -1624,22 +1599,22 @@ H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
/* Attempt to redistribute records among children */
if(idx == 0) { /* Left-most child */
if(retries > 0 && (internal->node_ptrs[idx + 1].node_nrec < split_nrec)) {
- if(H5B2_redistribute2(f, dxpl_id, depth, internal, idx) < 0)
+ if(H5B2_redistribute2(hdr, dxpl_id, depth, internal, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records")
} /* end if */
else {
- if(H5B2_split1(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_split1(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split child node")
} /* end else */
} /* end if */
else if(idx == internal->nrec) { /* Right-most child */
if(retries > 0 && (internal->node_ptrs[idx - 1].node_nrec < split_nrec)) {
- if(H5B2_redistribute2(f, dxpl_id, depth, internal, (idx - 1)) < 0)
+ if(H5B2_redistribute2(hdr, dxpl_id, depth, internal, (idx - 1)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records")
} /* end if */
else {
- if(H5B2_split1(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_split1(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split child node")
} /* end else */
@@ -1647,11 +1622,11 @@ H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
else { /* Middle child */
if(retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec < split_nrec) ||
(internal->node_ptrs[idx - 1].node_nrec < split_nrec))) {
- if(H5B2_redistribute3(f, dxpl_id, depth, internal, &internal_flags, idx) < 0)
+ if(H5B2_redistribute3(hdr, dxpl_id, depth, internal, &internal_flags, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records")
} /* end if */
else {
- if(H5B2_split1(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_split1(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split child node")
} /* end else */
@@ -1671,11 +1646,11 @@ H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
/* Attempt to insert node */
if(depth > 1) {
- if(H5B2_insert_internal(f, dxpl_id, hdr, (depth - 1), &internal_flags, &internal->node_ptrs[idx], udata) < 0)
+ if(H5B2_insert_internal(hdr, dxpl_id, (depth - 1), &internal_flags, &internal->node_ptrs[idx], udata) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node")
} /* end if */
else {
- if(H5B2_insert_leaf(f, dxpl_id, hdr, &internal->node_ptrs[idx], udata) < 0)
+ if(H5B2_insert_leaf(hdr, dxpl_id, &internal->node_ptrs[idx], udata) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node")
} /* end else */
@@ -1687,7 +1662,7 @@ H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
done:
/* Release the B-tree internal node */
- if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0)
+ if(internal && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1709,7 +1684,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_create_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *node_ptr)
+H5B2_create_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *node_ptr)
{
H5B2_leaf_t *leaf = NULL; /* Pointer to new leaf node created */
herr_t ret_value = SUCCEED;
@@ -1717,13 +1692,12 @@ H5B2_create_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *node
FUNC_ENTER_NOAPI_NOINIT(H5B2_create_leaf)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(node_ptr);
/* Allocate memory for leaf information */
if(NULL == (leaf = H5FL_MALLOC(H5B2_leaf_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf info")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf info")
/* Set metadata cache info */
HDmemset(&leaf->cache_info, 0, sizeof(H5AC_info_t));
@@ -1737,7 +1711,7 @@ H5B2_create_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, H5B2_node_ptr_t *node
/* Allocate space for the native keys in memory */
if(NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[0].nat_rec_fac)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf native keys")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf native keys")
#ifdef H5_CLEAR_MEMORY
HDmemset(leaf->leaf_native, 0, hdr->cls->nrec_size * hdr->node_info[0].max_nrec);
#endif /* H5_CLEAR_MEMORY */
@@ -1746,17 +1720,17 @@ HDmemset(leaf->leaf_native, 0, hdr->cls->nrec_size * hdr->node_info[0].max_nrec)
leaf->nrec = 0;
/* Allocate space on disk for the leaf */
- if(HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)hdr->node_size)))
+ if(HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)hdr->node_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree leaf node")
/* Cache the new B-tree node */
- if(H5AC_set(f, dxpl_id, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_set(hdr->f, dxpl_id, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree leaf to cache")
done:
if(ret_value < 0) {
if(leaf)
- (void)H5B2_cache_leaf_dest(f, leaf);
+ (void)H5B2_cache_leaf_dest(hdr->f, leaf);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -1778,8 +1752,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_create_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
- H5B2_node_ptr_t *node_ptr, unsigned depth)
+H5B2_create_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *node_ptr,
+ unsigned depth)
{
H5B2_internal_t *internal = NULL; /* Pointer to new internal node created */
herr_t ret_value = SUCCEED;
@@ -1787,7 +1761,6 @@ H5B2_create_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
FUNC_ENTER_NOAPI_NOINIT(H5B2_create_internal)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(node_ptr);
HDassert(depth > 0);
@@ -1808,14 +1781,14 @@ H5B2_create_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
/* Allocate space for the native keys in memory */
if(NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].nat_rec_fac)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys")
#ifdef H5_CLEAR_MEMORY
HDmemset(internal->int_native, 0, hdr->cls->nrec_size * hdr->node_info[depth].max_nrec);
#endif /* H5_CLEAR_MEMORY */
/* Allocate space for the node pointers in memory */
if(NULL == (internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].node_ptr_fac)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers")
#ifdef H5_CLEAR_MEMORY
HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (hdr->node_info[depth].max_nrec + 1));
#endif /* H5_CLEAR_MEMORY */
@@ -1825,17 +1798,17 @@ HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (hdr->node_info[depth
internal->depth = depth;
/* Allocate space on disk for the internal node */
- if(HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)hdr->node_size)))
+ if(HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)hdr->node_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree internal node")
/* Cache the new B-tree node */
- if(H5AC_set(f, dxpl_id, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_set(hdr->f, dxpl_id, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree internal node to cache")
done:
if(ret_value < 0) {
if(internal)
- (void)H5B2_cache_internal_dest(f, internal);
+ (void)H5B2_cache_internal_dest(hdr->f, internal);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -1856,7 +1829,7 @@ done:
*-------------------------------------------------------------------------
*/
H5B2_internal_t *
-H5B2_protect_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, haddr_t addr,
+H5B2_protect_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, haddr_t addr,
unsigned nrec, unsigned depth, H5AC_protect_t rw)
{
H5B2_int_load_ud1_t udata; /* User data to pass through to cache 'load' callback */
@@ -1865,7 +1838,6 @@ H5B2_protect_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, haddr_t addr,
FUNC_ENTER_NOAPI_NOINIT(H5B2_protect_internal)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(H5F_addr_defined(addr));
HDassert(depth > 0);
@@ -1876,7 +1848,7 @@ H5B2_protect_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, haddr_t addr,
udata.depth = depth;
/* Protect the internal node */
- if(NULL == (ret_value = (H5B2_internal_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_INT, addr, &udata, NULL, rw)))
+ if(NULL == (ret_value = (H5B2_internal_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_INT, addr, &udata, NULL, rw)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree internal node")
done:
@@ -1902,7 +1874,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
+H5B2_iterate_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
const H5B2_node_ptr_t *curr_node, H5B2_operator_t op, void *op_data)
{
const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */
@@ -1916,7 +1888,6 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
FUNC_ENTER_NOAPI_NOINIT(H5B2_iterate_node)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(curr_node);
HDassert(op);
@@ -1926,7 +1897,7 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
H5B2_internal_t *internal; /* Pointer to internal node */
/* Lock the current B-tree node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Set up information about current node */
@@ -1936,7 +1907,7 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
/* Allocate space for the node pointers in memory */
if(NULL == (node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].node_ptr_fac)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers")
/* Copy the node pointers */
HDmemcpy(node_ptrs, internal->node_ptrs, (sizeof(H5B2_node_ptr_t) * (curr_node->node_nrec + 1)));
@@ -1945,7 +1916,7 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
H5B2_leaf_t *leaf; /* Pointer to leaf node */
/* Lock the current B-tree node */
- if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node->addr, &(curr_node->node_nrec), hdr, H5AC_READ)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node->addr, &(curr_node->node_nrec), hdr, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* Set up information about current node */
@@ -1962,7 +1933,7 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
HDmemcpy(native, node_native, (hdr->cls->nrec_size * curr_node->node_nrec));
/* Unlock the node */
- if(H5AC_unprotect(f, dxpl_id, curr_node_class, curr_node->addr, node, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_unprotect(hdr->f, dxpl_id, curr_node_class, curr_node->addr, node, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
node = NULL;
@@ -1970,7 +1941,7 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
for(u = 0; u < curr_node->node_nrec && !ret_value; u++) {
/* Descend into child node, if current node is an internal node */
if(depth > 0) {
- if((ret_value = H5B2_iterate_node(f, dxpl_id, hdr, (depth - 1), &(node_ptrs[u]), op, op_data)) < 0)
+ if((ret_value = H5B2_iterate_node(hdr, dxpl_id, (depth - 1), &(node_ptrs[u]), op, op_data)) < 0)
HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed");
} /* end if */
@@ -1983,7 +1954,7 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
/* Descend into last child node, if current node is an internal node */
if(!ret_value && depth > 0) {
- if((ret_value = H5B2_iterate_node(f, dxpl_id, hdr, (depth - 1), &(node_ptrs[u]), op, op_data)) < 0)
+ if((ret_value = H5B2_iterate_node(hdr, dxpl_id, (depth - 1), &(node_ptrs[u]), op, op_data)) < 0)
HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed");
} /* end if */
@@ -2012,9 +1983,8 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
- H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op,
- void *op_data)
+H5B2_remove_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr,
+ void *udata, H5B2_remove_t op, void *op_data)
{
H5B2_leaf_t *leaf; /* Pointer to leaf node */
haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */
@@ -2025,14 +1995,13 @@ H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
FUNC_ENTER_NOAPI_NOINIT(H5B2_remove_leaf)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(curr_node_ptr);
HDassert(H5F_addr_defined(curr_node_ptr->addr));
/* Lock current B-tree node */
leaf_addr = curr_node_ptr->addr;
- if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, &(curr_node_ptr->node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, &(curr_node_ptr->node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* Sanity check number of records */
@@ -2072,7 +2041,7 @@ H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
done:
/* Release the B-tree leaf node */
- if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0)
+ if(leaf && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2093,11 +2062,10 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
- hbool_t *depth_decreased, void *swap_loc, unsigned depth,
- H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr,
- H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op,
- void *op_data)
+H5B2_remove_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, hbool_t *depth_decreased,
+ void *swap_loc, unsigned depth, H5AC_info_t *parent_cache_info,
+ unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr,
+ void *udata, H5B2_remove_t op, void *op_data)
{
H5AC_info_t *new_cache_info; /* Pointer to new cache info */
unsigned *new_cache_info_flags_ptr = NULL;
@@ -2112,7 +2080,6 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
FUNC_ENTER_NOAPI_NOINIT(H5B2_remove_internal)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(depth > 0);
HDassert(parent_cache_info);
@@ -2121,7 +2088,7 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
/* Lock current B-tree node */
internal_addr = curr_node_ptr->addr;
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, internal_addr, curr_node_ptr->node_nrec, depth, H5AC_WRITE)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, internal_addr, curr_node_ptr->node_nrec, depth, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Determine the correct number of records to merge at */
@@ -2133,7 +2100,7 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
((internal->node_ptrs[0].node_nrec + internal->node_ptrs[1].node_nrec) <= ((merge_nrec * 2) + 1))) {
/* Merge children of root node */
- if(H5B2_merge2(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_merge2(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, 0) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node")
@@ -2189,22 +2156,22 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
*/
if(idx == 0) { /* Left-most child */
if(retries > 0 && (internal->node_ptrs[idx + 1].node_nrec > merge_nrec)) {
- if(H5B2_redistribute2(f, dxpl_id, depth, internal, idx) < 0)
+ if(H5B2_redistribute2(hdr, dxpl_id, depth, internal, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records")
} /* end if */
else {
- if(H5B2_merge2(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_merge2(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node")
} /* end else */
} /* end if */
else if(idx == internal->nrec) { /* Right-most child */
if(retries > 0 && (internal->node_ptrs[idx - 1].node_nrec > merge_nrec)) {
- if(H5B2_redistribute2(f, dxpl_id, depth, internal, (idx - 1)) < 0)
+ if(H5B2_redistribute2(hdr, dxpl_id, depth, internal, (idx - 1)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records")
} /* end if */
else {
- if(H5B2_merge2(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_merge2(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, (idx - 1)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node")
} /* end else */
@@ -2212,11 +2179,11 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
else { /* Middle child */
if(retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec > merge_nrec) ||
(internal->node_ptrs[idx - 1].node_nrec > merge_nrec))) {
- if(H5B2_redistribute3(f, dxpl_id, depth, internal, &internal_flags, idx) < 0)
+ if(H5B2_redistribute3(hdr, dxpl_id, depth, internal, &internal_flags, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records")
} /* end if */
else {
- if(H5B2_merge3(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_merge3(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node")
} /* end else */
@@ -2242,7 +2209,7 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
/* Swap record to delete with record from leaf, if we are the last internal node */
if(swap_loc && depth == 1)
- if(H5B2_swap_leaf(f, dxpl_id, depth, internal, &internal_flags, idx, swap_loc) < 0)
+ if(H5B2_swap_leaf(hdr, dxpl_id, depth, internal, &internal_flags, idx, swap_loc) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSWAP, FAIL, "Can't swap records in B-tree")
/* Set pointers for advancing to child node */
@@ -2253,12 +2220,12 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
/* Attempt to remove record from child node */
if(depth > 1) {
- if(H5B2_remove_internal(f, dxpl_id, hdr, depth_decreased, swap_loc, depth - 1,
+ if(H5B2_remove_internal(hdr, dxpl_id, depth_decreased, swap_loc, depth - 1,
new_cache_info, new_cache_info_flags_ptr, new_node_ptr, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node")
} /* end if */
else {
- if(H5B2_remove_leaf(f, dxpl_id, hdr, new_node_ptr, udata, op, op_data) < 0)
+ if(H5B2_remove_leaf(hdr, dxpl_id, new_node_ptr, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node")
} /* end else */
@@ -2275,7 +2242,7 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
done:
/* Release the B-tree internal node */
- if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0)
+ if(internal && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2297,7 +2264,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5B2_remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *curr_node_ptr, unsigned idx, H5B2_remove_t op,
void *op_data)
{
@@ -2309,14 +2276,13 @@ H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
FUNC_ENTER_NOAPI_NOINIT(H5B2_remove_leaf_by_idx)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(curr_node_ptr);
HDassert(H5F_addr_defined(curr_node_ptr->addr));
/* Lock B-tree leaf node */
leaf_addr = curr_node_ptr->addr;
- if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, &(curr_node_ptr->node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, &(curr_node_ptr->node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* Sanity check number of records */
@@ -2353,7 +2319,7 @@ H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
done:
/* Release the B-tree leaf node */
- if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0)
+ if(leaf && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2375,7 +2341,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5B2_remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
hbool_t *depth_decreased, void *swap_loc, unsigned depth,
H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr,
H5B2_node_ptr_t *curr_node_ptr, hsize_t n, H5B2_remove_t op,
@@ -2394,7 +2360,6 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
FUNC_ENTER_NOAPI_NOINIT(H5B2_remove_internal_by_idx)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(depth > 0);
HDassert(parent_cache_info);
@@ -2403,7 +2368,7 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
/* Lock current B-tree node */
internal_addr = curr_node_ptr->addr;
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, internal_addr, curr_node_ptr->node_nrec, depth, H5AC_WRITE)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, internal_addr, curr_node_ptr->node_nrec, depth, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
HDassert(internal->nrec == curr_node_ptr->node_nrec);
HDassert(depth == hdr->depth || internal->nrec > 1);
@@ -2418,7 +2383,7 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
HDassert(depth == hdr->depth);
/* Merge children of root node */
- if(H5B2_merge2(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_merge2(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, 0) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node")
@@ -2497,22 +2462,22 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
*/
if(idx == 0) { /* Left-most child */
if(retries > 0 && (internal->node_ptrs[idx + 1].node_nrec > merge_nrec)) {
- if(H5B2_redistribute2(f, dxpl_id, depth, internal, idx) < 0)
+ if(H5B2_redistribute2(hdr, dxpl_id, depth, internal, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records")
} /* end if */
else {
- if(H5B2_merge2(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_merge2(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node")
} /* end else */
} /* end if */
else if(idx == internal->nrec) { /* Right-most child */
if(retries > 0 && (internal->node_ptrs[idx - 1].node_nrec > merge_nrec)) {
- if(H5B2_redistribute2(f, dxpl_id, depth, internal, (idx - 1)) < 0)
+ if(H5B2_redistribute2(hdr, dxpl_id, depth, internal, (idx - 1)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records")
} /* end if */
else {
- if(H5B2_merge2(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_merge2(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, (idx - 1)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node")
} /* end else */
@@ -2520,11 +2485,11 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
else { /* Middle child */
if(retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec > merge_nrec) ||
(internal->node_ptrs[idx - 1].node_nrec > merge_nrec))) {
- if(H5B2_redistribute3(f, dxpl_id, depth, internal, &internal_flags, idx) < 0)
+ if(H5B2_redistribute3(hdr, dxpl_id, depth, internal, &internal_flags, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records")
} /* end if */
else {
- if(H5B2_merge3(f, dxpl_id, depth, curr_node_ptr,
+ if(H5B2_merge3(hdr, dxpl_id, depth, curr_node_ptr,
parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node")
} /* end else */
@@ -2579,7 +2544,7 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
/* Swap record to delete with record from leaf, if we are the last internal node */
if(swap_loc && depth == 1)
- if(H5B2_swap_leaf(f, dxpl_id, depth, internal, &internal_flags, idx, swap_loc) < 0)
+ if(H5B2_swap_leaf(hdr, dxpl_id, depth, internal, &internal_flags, idx, swap_loc) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSWAP, FAIL, "can't swap records in B-tree")
/* Set pointers for advancing to child node */
@@ -2590,12 +2555,12 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
/* Attempt to remove record from child node */
if(depth > 1) {
- if(H5B2_remove_internal_by_idx(f, dxpl_id, hdr, depth_decreased, swap_loc, depth - 1,
+ if(H5B2_remove_internal_by_idx(hdr, dxpl_id, depth_decreased, swap_loc, depth - 1,
new_cache_info, new_cache_info_flags_ptr, new_node_ptr, n, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node")
} /* end if */
else {
- if(H5B2_remove_leaf_by_idx(f, dxpl_id, hdr, new_node_ptr, (unsigned)n, op, op_data) < 0)
+ if(H5B2_remove_leaf_by_idx(hdr, dxpl_id, new_node_ptr, (unsigned)n, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node")
} /* end else */
@@ -2612,7 +2577,7 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
done:
/* Release the B-tree internal node */
- if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0)
+ if(internal && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2646,9 +2611,9 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
- H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc,
- H5B2_compare_t comp, void *udata, H5B2_found_t op, void *op_data)
+H5B2_neighbor_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr,
+ void *neighbor_loc, H5B2_compare_t comp, void *udata, H5B2_found_t op,
+ void *op_data)
{
H5B2_leaf_t *leaf; /* Pointer to leaf node */
unsigned idx; /* Location of record which matches key */
@@ -2658,14 +2623,13 @@ H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
FUNC_ENTER_NOAPI_NOINIT(H5B2_neighbor_leaf)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(curr_node_ptr);
HDassert(H5F_addr_defined(curr_node_ptr->addr));
HDassert(op);
/* Lock current B-tree node */
- if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, &(curr_node_ptr->node_nrec), hdr, H5AC_READ)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, &(curr_node_ptr->node_nrec), hdr, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* Locate node pointer for child */
@@ -2699,7 +2663,7 @@ H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
done:
/* Release the B-tree internal node */
- if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(leaf && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2733,19 +2697,18 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_neighbor_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
- unsigned depth, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc,
- H5B2_compare_t comp, void *udata, H5B2_found_t op, void *op_data)
+H5B2_neighbor_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
+ H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, H5B2_compare_t comp,
+ void *udata, H5B2_found_t op, void *op_data)
{
H5B2_internal_t *internal; /* Pointer to internal node */
unsigned idx; /* Location of record which matches key */
- int cmp = 0; /* Comparison value of records */
+ int cmp = 0; /* Comparison value of records */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT(H5B2_neighbor_internal)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(depth > 0);
HDassert(curr_node_ptr);
@@ -2753,7 +2716,7 @@ H5B2_neighbor_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
HDassert(op);
/* Lock current B-tree node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate node pointer for child */
@@ -2775,17 +2738,17 @@ H5B2_neighbor_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
/* Attempt to find neighboring record */
if(depth > 1) {
- if(H5B2_neighbor_internal(f, dxpl_id, hdr, depth - 1, &internal->node_ptrs[idx], neighbor_loc, comp, udata, op, op_data) < 0)
+ if(H5B2_neighbor_internal(hdr, dxpl_id, depth - 1, &internal->node_ptrs[idx], neighbor_loc, comp, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree internal node")
} /* end if */
else {
- if(H5B2_neighbor_leaf(f, dxpl_id, hdr, &internal->node_ptrs[idx], neighbor_loc, comp, udata, op, op_data) < 0)
+ if(H5B2_neighbor_leaf(hdr, dxpl_id, &internal->node_ptrs[idx], neighbor_loc, comp, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree leaf node")
} /* end else */
done:
/* Release the B-tree internal node */
- if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(internal && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2807,7 +2770,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
+H5B2_delete_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
const H5B2_node_ptr_t *curr_node, H5B2_remove_t op, void *op_data)
{
const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */
@@ -2818,7 +2781,6 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
FUNC_ENTER_NOAPI_NOINIT(H5B2_delete_node)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(curr_node);
@@ -2827,7 +2789,7 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
unsigned u; /* Local index */
/* Lock the current B-tree node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, curr_node->addr, curr_node->node_nrec, depth, H5AC_WRITE)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node->addr, curr_node->node_nrec, depth, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Set up information about current node */
@@ -2837,14 +2799,14 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
/* Descend into children */
for(u = 0; u < internal->nrec + 1; u++)
- if(H5B2_delete_node(f, dxpl_id, hdr, depth - 1, &(internal->node_ptrs[u]), op, op_data) < 0)
+ if(H5B2_delete_node(hdr, dxpl_id, depth - 1, &(internal->node_ptrs[u]), op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node descent failed")
} /* end if */
else {
H5B2_leaf_t *leaf; /* Pointer to leaf node */
/* Lock the current B-tree node */
- if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node->addr, &(curr_node->node_nrec), hdr, H5AC_WRITE)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node->addr, &(curr_node->node_nrec), hdr, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* Set up information about current node */
@@ -2867,7 +2829,7 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
done:
/* Unlock & delete current node */
- if(node && H5AC_unprotect(f, dxpl_id, curr_node_class, curr_node->addr, node, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0)
+ if(node && H5AC_unprotect(hdr->f, dxpl_id, curr_node_class, curr_node->addr, node, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2888,7 +2850,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
+H5B2_iterate_size_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
const H5B2_node_ptr_t *curr_node, hsize_t *btree_size)
{
H5B2_internal_t *internal = NULL; /* Pointer to internal node */
@@ -2897,14 +2859,13 @@ H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
FUNC_ENTER_NOAPI(H5B2_iterate_size_node, FAIL)
/* Check arguments. */
- HDassert(f);
HDassert(hdr);
HDassert(curr_node);
HDassert(btree_size);
HDassert(depth > 0);
/* Lock the current B-tree node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Recursively descend into child nodes, if we are above the "twig" level in the B-tree */
@@ -2913,7 +2874,7 @@ H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
/* Descend into children */
for(u = 0; u < internal->nrec + 1; u++)
- if(H5B2_iterate_size_node(f, dxpl_id, hdr, (depth - 1), &(internal->node_ptrs[u]), btree_size) < 0)
+ if(H5B2_iterate_size_node(hdr, dxpl_id, (depth - 1), &(internal->node_ptrs[u]), btree_size) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed")
} /* end if */
else /* depth is 1: count all the leaf nodes from this node */
@@ -2923,7 +2884,7 @@ H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr, unsigned depth,
*btree_size += hdr->node_size;
done:
- if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(internal && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h
index 3961fb5..6323989 100644
--- a/src/H5B2pkg.h
+++ b/src/H5B2pkg.h
@@ -48,10 +48,10 @@
#define H5B2_TREE_POINTER_SIZE(f) (H5F_SIZEOF_ADDR(f)+H5B2_SIZEOF_RECORDS_PER_NODE+H5F_SIZEOF_SIZE(f))
/* Size of a internal node pointer (on disk) */
-#define H5B2_INT_POINTER_SIZE(f, s, d) ( \
- H5F_SIZEOF_ADDR(f) /* Address of child node */ \
- + (s)->max_nrec_size /* # of records in child node */ \
- + (s)->node_info[(d) - 1].cum_max_nrec_size /* Total # of records in child & below */ \
+#define H5B2_INT_POINTER_SIZE(h, d) ( \
+ (h)->sizeof_addr /* Address of child node */ \
+ + (h)->max_nrec_size /* # of records in child node */ \
+ + (h)->node_info[(d) - 1].cum_max_nrec_size /* Total # of records in child & below */ \
)
/* Size of checksum information (on disk) */
@@ -108,8 +108,8 @@
/* Number of records that fit into internal node */
/* (accounts for extra node pointer by counting it in with the prefix bytes) */
-#define H5B2_NUM_INT_REC(f, s, d) \
- (((s)->node_size - (H5B2_INT_PREFIX_SIZE + H5B2_INT_POINTER_SIZE(f, s, d))) / ((s)->rrec_size + H5B2_INT_POINTER_SIZE(f, s, d)))
+#define H5B2_NUM_INT_REC(h, d) \
+ (((h)->node_size - (H5B2_INT_PREFIX_SIZE + H5B2_INT_POINTER_SIZE(h, d))) / ((h)->rrec_size + H5B2_INT_POINTER_SIZE(h, d)))
/****************************/
@@ -160,6 +160,8 @@ typedef struct H5B2_hdr_t {
size_t rc; /* Reference count of nodes using this header */
size_t file_rc; /* Reference count of files using this header */
hbool_t pending_delete; /* B-tree is pending deletion */
+ size_t sizeof_size; /* Size of file sizes */
+ size_t sizeof_addr; /* Size of file addresses */
H5B2_remove_t remove_op; /* Callback operator for deleting B-tree */
void *remove_op_data;/* B-tree deletion callback's context */
const H5B2_class_t *cls; /* Class of B-tree client */
@@ -258,58 +260,56 @@ H5_DLL herr_t H5B2_hdr_free(H5B2_hdr_t *hdr);
H5_DLL herr_t H5B2_hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id);
/* Routines for operating on internal nodes */
-H5_DLL H5B2_internal_t *H5B2_protect_internal(H5F_t *f, hid_t dxpl_id,
- H5B2_hdr_t *hdr, haddr_t addr, unsigned nrec, unsigned depth, H5AC_protect_t rw);
+H5_DLL H5B2_internal_t *H5B2_protect_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
+ haddr_t addr, unsigned nrec, unsigned depth, H5AC_protect_t rw);
/* Routines for allocating nodes */
-H5_DLL herr_t H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr);
-H5_DLL herr_t H5B2_create_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5_DLL herr_t H5B2_split_root(H5B2_hdr_t *hdr, hid_t dxpl_id);
+H5_DLL herr_t H5B2_create_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *node_ptr);
/* Routines for inserting records */
-H5_DLL herr_t H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5_DLL herr_t H5B2_insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
unsigned depth, unsigned *parent_cache_info_flags_ptr,
H5B2_node_ptr_t *curr_node_ptr, void *udata);
-H5_DLL herr_t H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5_DLL herr_t H5B2_insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *curr_node_ptr, void *udata);
/* Routines for iterating over nodes/records */
-H5_DLL herr_t H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
- unsigned depth, const H5B2_node_ptr_t *curr_node, H5B2_operator_t op,
- void *op_data);
-H5_DLL herr_t H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5_DLL herr_t H5B2_iterate_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
+ const H5B2_node_ptr_t *curr_node, H5B2_operator_t op, void *op_data);
+H5_DLL herr_t H5B2_iterate_size_node(H5B2_hdr_t *hdr, hid_t dxpl_id,
unsigned depth, const H5B2_node_ptr_t *curr_node, hsize_t *op_data);
/* Routines for locating records */
H5_DLL int H5B2_locate_record(const H5B2_class_t *type, unsigned nrec,
size_t *rec_off, const uint8_t *native, const void *udata, unsigned *idx);
-H5_DLL herr_t H5B2_neighbor_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5_DLL herr_t H5B2_neighbor_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
unsigned depth, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc,
H5B2_compare_t comp, void *udata, H5B2_found_t op, void *op_data);
-H5_DLL herr_t H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5_DLL herr_t H5B2_neighbor_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc,
H5B2_compare_t comp, void *udata, H5B2_found_t op, void *op_data);
/* Routines for removing records */
-H5_DLL herr_t H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5_DLL herr_t H5B2_remove_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
hbool_t *depth_decreased, void *swap_loc, unsigned depth, H5AC_info_t *parent_cache_info,
hbool_t * parent_cache_info_dirtied_ptr, H5B2_node_ptr_t *curr_node_ptr, void *udata,
H5B2_remove_t op, void *op_data);
-H5_DLL herr_t H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5_DLL herr_t H5B2_remove_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op,
void *op_data);
-H5_DLL herr_t H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5_DLL herr_t H5B2_remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
hbool_t *depth_decreased, void *swap_loc, unsigned depth, H5AC_info_t *parent_cache_info,
hbool_t * parent_cache_info_dirtied_ptr, H5B2_node_ptr_t *curr_node_ptr, hsize_t idx,
H5B2_remove_t op, void *op_data);
-H5_DLL herr_t H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
+H5_DLL herr_t H5B2_remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *curr_node_ptr, unsigned idx, H5B2_remove_t op,
void *op_data);
/* Routines for deleting nodes */
-H5_DLL herr_t H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5B2_hdr_t *hdr,
- unsigned depth, const H5B2_node_ptr_t *curr_node, H5B2_remove_t op,
- void *op_data);
+H5_DLL herr_t H5B2_delete_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
+ const H5B2_node_ptr_t *curr_node, H5B2_remove_t op, void *op_data);
/* Metadata cache callbacks */
H5_DLL herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_hdr_t *b);
diff --git a/src/H5B2test.c b/src/H5B2test.c
index b29fde1..6722c28 100644
--- a/src/H5B2test.c
+++ b/src/H5B2test.c
@@ -321,7 +321,7 @@ H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *cls,
H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */
/* Lock B-tree current node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, hdr, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate node pointer for child */
diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c
index 691b349..141e1f2 100644
--- a/src/H5Dbtree.c
+++ b/src/H5Dbtree.c
@@ -1040,7 +1040,7 @@ H5D_btree_idx_iterate_cb(H5F_t UNUSED *f, hid_t UNUSED dxpl_id,
H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */
int ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5D_btree_idx_iterate_cb)
+ FUNC_ENTER_NOAPI_NOINIT_NOERR(H5D_btree_idx_iterate_cb)
/* Sanity check for memcpy() */
HDcompile_assert(offsetof(H5D_chunk_rec_t, nbytes) == offsetof(H5D_btree_key_t, nbytes));
@@ -1082,7 +1082,7 @@ H5D_btree_idx_iterate(const H5D_chk_idx_info_t *idx_info,
H5D_btree_it_ud_t udata; /* User data for B-tree iterator callback */
int ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5D_btree_idx_iterate)
+ FUNC_ENTER_NOAPI_NOINIT_NOERR(H5D_btree_idx_iterate)
HDassert(idx_info);
HDassert(idx_info->f);
diff --git a/src/H5Doh.c b/src/H5Doh.c
index becf245..42ec606 100644
--- a/src/H5Doh.c
+++ b/src/H5Doh.c
@@ -401,7 +401,7 @@ H5O_dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
if((exists = H5O_msg_exists_oh(oh, H5O_EFL_ID)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for EFL message")
- if(exists && H5D_efl_is_space_alloc(&layout)) {
+ if(exists && H5D_efl_is_space_alloc(&layout.storage)) {
H5O_efl_t efl; /* External File List message */
/* Start with clean EFL info */
diff --git a/src/H5Glink.c b/src/H5Glink.c
index 37a0ede..488c05b 100644
--- a/src/H5Glink.c
+++ b/src/H5Glink.c
@@ -609,7 +609,7 @@ H5G_link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip,
size_t u; /* Local index variable */
herr_t ret_value = H5_ITER_CONT; /* Return value */
- FUNC_ENTER_NOAPI(H5G_link_iterate_table, FAIL)
+ FUNC_ENTER_NOAPI_NOERR(H5G_link_iterate_table, -)
/* Sanity check */
HDassert(ltable);
diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c
index 7030da5..bda9832 100644
--- a/src/H5HGdbg.c
+++ b/src/H5HGdbg.c
@@ -93,7 +93,10 @@ H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
fprintf (stream, "%*s%-*s %u/%lu/", indent, "", fwidth,
"Objects defined/allocated/max:",
nused, (unsigned long)h->nalloc);
- fprintf (stream, nused ? "%u\n": "NA\n", maxobj);
+ if(nused)
+ fprintf(stream, "%u\n", maxobj);
+ else
+ fprintf(stream, "NA\n");
fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Free space:",
diff --git a/src/H5WB.c b/src/H5WB.c
index e53c70c..c3e3a6f 100644
--- a/src/H5WB.c
+++ b/src/H5WB.c
@@ -284,7 +284,7 @@ H5WB_unwrap(H5WB_t *wb)
} /* end if */
/* Release the buffer wrapper info */
- H5FL_FREE(H5WB_t, wb);
+ wb = H5FL_FREE(H5WB_t, wb);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5WB_unwrap() */
diff --git a/src/H5detect.c b/src/H5detect.c
index d5801ef..f76f159 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -823,7 +823,7 @@ done:\n\
if(dt != NULL) {\n\
if(dt->shared != NULL)\n\
H5FL_FREE(H5T_shared_t, dt->shared);\n\
- H5FL_FREE(H5T_t, dt);\n\
+ dt = H5FL_FREE(H5T_t, dt);\n\
} /* end if */\n\
} /* end if */\n\
\n\
diff --git a/src/H5private.h b/src/H5private.h
index 035f6db..65800fc 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -1748,10 +1748,14 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
#define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt)
#endif /* NDEBUG */
-#define FUNC_ENTER_COMMON(func_name,asrt) \
- static const char FUNC[]=#func_name; \
+#define FUNC_ENTER_COMMON(func_name, asrt) \
+ static const char FUNC[] = #func_name; \
hbool_t err_occurred = FALSE; \
- FUNC_ENTER_COMMON_NOFUNC(func_name,asrt);
+ FUNC_ENTER_COMMON_NOFUNC(func_name, asrt);
+
+#define FUNC_ENTER_COMMON_NOERR(func_name, asrt) \
+ static const char FUNC[] = #func_name; \
+ FUNC_ENTER_COMMON_NOFUNC(func_name, asrt);
/* Threadsafety initialization code for API routines */
#define FUNC_ENTER_API_THREADSAFE \
@@ -1762,22 +1766,37 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
H5_API_UNSET_CANCEL \
H5_API_LOCK
-/* Threadsafety termination code for API routines */
-#define FUNC_LEAVE_API_THREADSAFE \
- H5_API_UNLOCK \
- H5_API_SET_CANCEL
-
/* Local variables for API routines */
#define FUNC_ENTER_API_VARS(func_name) \
MPE_LOG_VARS(func_name) \
H5TRACE_DECL
+#define FUNC_ENTER_API_COMMON(func_name) \
+ FUNC_ENTER_API_VARS(func_name) \
+ FUNC_ENTER_COMMON(func_name, H5_IS_API(#func_name)); \
+ FUNC_ENTER_API_THREADSAFE;
+
+#define FUNC_ENTER_API_INIT(func_name,err) \
+ /* Initialize the library */ \
+ if(!(H5_INIT_GLOBAL)) { \
+ H5_INIT_GLOBAL = TRUE; \
+ if(H5_init_library() < 0) \
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, \
+ "library initialization failed") \
+ } \
+ \
+ /* Initialize the interface, if appropriate */ \
+ H5_INTERFACE_INIT(err) \
+ \
+ /* Push the name of this function on the function stack */ \
+ H5_PUSH_FUNC(#func_name) \
+ \
+ BEGIN_MPE_LOG(func_name)
+
/* Use this macro for all "normal" API functions */
#define FUNC_ENTER_API(func_name,err) {{ \
- FUNC_ENTER_API_VARS(func_name) \
- FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name)); \
- FUNC_ENTER_API_THREADSAFE; \
- FUNC_ENTER_API_COMMON(func_name,err); \
+ FUNC_ENTER_API_COMMON(func_name) \
+ FUNC_ENTER_API_INIT(func_name,err); \
/* Clear thread error stack entering public functions */ \
H5E_clear_stack(NULL); \
{
@@ -1787,10 +1806,8 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
* like H5Eprint and H5Ewalk.
*/
#define FUNC_ENTER_API_NOCLEAR(func_name,err) {{ \
- FUNC_ENTER_API_VARS(func_name) \
- FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name)); \
- FUNC_ENTER_API_THREADSAFE; \
- FUNC_ENTER_API_COMMON(func_name,err); \
+ FUNC_ENTER_API_COMMON(func_name) \
+ FUNC_ENTER_API_INIT(func_name,err); \
{
/*
@@ -1800,9 +1817,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
*
*/
#define FUNC_ENTER_API_NOINIT(func_name) {{ \
- FUNC_ENTER_API_VARS(func_name) \
- FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name)); \
- FUNC_ENTER_API_THREADSAFE; \
+ FUNC_ENTER_API_COMMON(func_name) \
H5_PUSH_FUNC(#func_name) \
BEGIN_MPE_LOG(func_name); \
{
@@ -1814,16 +1829,30 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
* are: H5close, H5check_version, etc.
*
*/
-#define FUNC_ENTER_API_NOINIT_NOFS(func_name) {{ \
+#define FUNC_ENTER_API_NOINIT_NOERR_NOFS(func_name) {{ \
FUNC_ENTER_API_VARS(func_name) \
- FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name)); \
- FUNC_ENTER_API_THREADSAFE; \
+ FUNC_ENTER_COMMON_NOERR(func_name, H5_IS_API(#func_name)); \
+ FUNC_ENTER_API_THREADSAFE; \
BEGIN_MPE_LOG(func_name); \
{
+/* Note: this macro only works when there's _no_ interface initialization routine for the module */
+#define FUNC_ENTER_NOAPI_INIT(func_name,err) \
+ /* Initialize the interface, if appropriate */ \
+ H5_INTERFACE_INIT(err) \
+ \
+ /* Push the name of this function on the function stack */ \
+ H5_PUSH_FUNC(#func_name)
+
/* Use this macro for all "normal" non-API functions */
#define FUNC_ENTER_NOAPI(func_name,err) { \
- FUNC_ENTER_COMMON(func_name,!H5_IS_API(#func_name)); \
+ FUNC_ENTER_COMMON(func_name, !H5_IS_API(#func_name)); \
+ FUNC_ENTER_NOAPI_INIT(func_name,err) \
+ {
+
+/* Use this macro for all non-API functions, which propagate errors, but don't issue them */
+#define FUNC_ENTER_NOAPI_NOERR(func_name,err) { \
+ FUNC_ENTER_COMMON_NOERR(func_name, !H5_IS_API(#func_name)); \
FUNC_ENTER_NOAPI_INIT(func_name,err) \
{
@@ -1841,8 +1870,22 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
* - functions which are called during library shutdown, since we don't
* want to re-initialize the library.
*/
-#define FUNC_ENTER_NOAPI_NOINIT(func_name) { \
- FUNC_ENTER_COMMON(func_name,!H5_IS_API(#func_name)); \
+#define FUNC_ENTER_NOAPI_NOINIT(func_name) { \
+ FUNC_ENTER_COMMON(func_name, !H5_IS_API(#func_name)); \
+ H5_PUSH_FUNC(#func_name) \
+ {
+
+/*
+ * Use this macro for non-API functions which fall into these categories:
+ * - static functions, since they must be called from a function in the
+ * interface, the library and interface must already be
+ * initialized.
+ * - functions which are called during library shutdown, since we don't
+ * want to re-initialize the library.
+ * - functions that propagate, but don't issue errors
+ */
+#define FUNC_ENTER_NOAPI_NOINIT_NOERR(func_name) { \
+ FUNC_ENTER_COMMON_NOERR(func_name, !H5_IS_API(#func_name)); \
H5_PUSH_FUNC(#func_name) \
{
@@ -1876,31 +1919,6 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \
{
-#define FUNC_ENTER_API_COMMON(func_name,err) \
- /* Initialize the library */ \
- if (!(H5_INIT_GLOBAL)) { \
- H5_INIT_GLOBAL = TRUE; \
- if (H5_init_library()<0) \
- HGOTO_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
- "library initialization failed") \
- } \
- \
- /* Initialize the interface, if appropriate */ \
- H5_INTERFACE_INIT(err) \
- \
- /* Push the name of this function on the function stack */ \
- H5_PUSH_FUNC(#func_name) \
- \
- BEGIN_MPE_LOG(func_name)
-
-/* Note: this macro only works when there's _no_ interface initialization routine for the module */
-#define FUNC_ENTER_NOAPI_INIT(func_name,err) \
- /* Initialize the interface, if appropriate */ \
- H5_INTERFACE_INIT(err) \
- \
- /* Push the name of this function on the function stack */ \
- H5_PUSH_FUNC(#func_name)
-
/*-------------------------------------------------------------------------
* Purpose: Register function exit for code profiling. This should be
* the last statement executed by a function.
@@ -1917,6 +1935,11 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
*
*-------------------------------------------------------------------------
*/
+/* Threadsafety termination code for API routines */
+#define FUNC_LEAVE_API_THREADSAFE \
+ H5_API_UNLOCK \
+ H5_API_SET_CANCEL
+
#define FUNC_LEAVE_API(ret_value) \
FINISH_MPE_LOG; \
H5TRACE_RETURN(ret_value); \
@@ -1924,28 +1947,26 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
if(err_occurred) \
(void)H5E_dump_api_stack(TRUE); \
FUNC_LEAVE_API_THREADSAFE \
- return (ret_value); \
+ return(ret_value); \
} /*end scope from end of FUNC_ENTER*/ \
}} /*end scope from beginning of FUNC_ENTER*/
#define FUNC_LEAVE_API_NOFS(ret_value) \
FINISH_MPE_LOG; \
H5TRACE_RETURN(ret_value); \
- if(err_occurred) \
- (void)H5E_dump_api_stack(TRUE); \
FUNC_LEAVE_API_THREADSAFE \
- return (ret_value); \
+ return(ret_value); \
} /*end scope from end of FUNC_ENTER*/ \
}} /*end scope from beginning of FUNC_ENTER*/
#define FUNC_LEAVE_NOAPI(ret_value) \
- H5_POP_FUNC \
- return (ret_value); \
+ H5_POP_FUNC \
+ return(ret_value); \
} /*end scope from end of FUNC_ENTER*/ \
} /*end scope from beginning of FUNC_ENTER*/
#define FUNC_LEAVE_NOAPI_VOID \
- H5_POP_FUNC \
+ H5_POP_FUNC \
return; \
} /*end scope from end of FUNC_ENTER*/ \
} /*end scope from beginning of FUNC_ENTER*/
@@ -1956,7 +1977,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
* (so far, just the H5CS routines themselves)
*/
#define FUNC_LEAVE_NOAPI_NOFS(ret_value) \
- return (ret_value); \
+ return(ret_value); \
} /*end scope from end of FUNC_ENTER*/ \
} /*end scope from beginning of FUNC_ENTER*/
diff --git a/src/H5trace.c b/src/H5trace.c
index 997eba2..b554b80 100644
--- a/src/H5trace.c
+++ b/src/H5trace.c
@@ -1454,7 +1454,7 @@ H5_trace (const double *returning, const char *func, const char *type, ...)
/* This may generate recursive call to the library... -QAK */
if(NULL != (pclass = (H5P_genclass_t *)H5I_object(pclass_id)) &&
(class_name = H5P_get_class_name(pclass))!=NULL) {
- fprintf (out, class_name);
+ fprintf(out, "%s", class_name);
H5MM_xfree(class_name);
} /* end if */
else {