summaryrefslogtreecommitdiffstats
path: root/src/H5B.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1999-07-28 18:25:43 (GMT)
committerRobb Matzke <matzke@llnl.gov>1999-07-28 18:25:43 (GMT)
commite4834c43ce6528308ebd5375bd4c7a0df88af427 (patch)
tree0039040d95cc92fdb197b2902436e32a020a7b6f /src/H5B.c
parent139688863f191366fe27fbab9654a52285e63c11 (diff)
downloadhdf5-e4834c43ce6528308ebd5375bd4c7a0df88af427.zip
hdf5-e4834c43ce6528308ebd5375bd4c7a0df88af427.tar.gz
hdf5-e4834c43ce6528308ebd5375bd4c7a0df88af427.tar.bz2
[svn-r1548] Changes since 19990727
---------------------- ./src/H5.c [1.3] ./src/H5AC.c [1.3] ./src/H5ACprivate.h [1.3] ./src/H5B.c [1.3] ./src/H5Bprivate.h [1.3] ./src/H5D.c [1.3] ./src/H5F.c [1.3] ./src/H5Farray.c [1.3] ./src/H5Fcore.c [1.3] ./src/H5Ffamily.c [1.3] ./src/H5Fistore.c [1.3] ./src/H5Flow.c [1.3] ./src/H5Fmpio.c [1.3] ./src/H5Fprivate.h [1.3] ./src/H5Fsec2.c [1.3] ./src/H5Fsplit.c [1.3] ./src/H5Fstdio.c [1.3] ./src/H5G.c [1.3] ./src/H5Gent.c [1.3] ./src/H5Gnode.c [1.3] ./src/H5Gprivate.h [1.3] ./src/H5Gstab.c [1.3] ./src/H5HG.c [1.3] ./src/H5HGprivate.h [1.3] ./src/H5HL.c [1.3] ./src/H5HLprivate.h [1.3] ./src/H5MF.c [1.3] ./src/H5MFprivate.h [1.3] ./src/H5O.c [1.3] ./src/H5Oattr.c [1.3] ./src/H5Ocont.c [1.3] ./src/H5Odtype.c [1.3] ./src/H5Oefl.c [1.3] ./src/H5Olayout.c [1.3] ./src/H5Oprivate.h [1.3] ./src/H5Oshared.c [1.3] ./src/H5Ostab.c [1.3] ./src/H5P.c [1.3] ./src/H5R.c [1.3] ./src/H5Smpio.c [1.3] ./src/H5T.c [1.3] ./src/H5Tvlen.c [1.3] ./src/H5private.h [1.3] ./test/dtypes.c [1.3] ./test/gheap.c [1.3] ./test/istore.c [1.3] ./test/lheap.c [1.3] ./test/ohdr.c [1.3] ./tools/h5debug.c [1.3] File addresses (the `haddr_t' type) are passed by value instead of by reference. The type is no longer a struct. This is one of the preliminary changes needed for the Virtual File Layer stuff. ./src/H5Fprivate.h [1.3] ./src/H5Flow.c [1.3] Some address functions were rewritten as macros.
Diffstat (limited to 'src/H5B.c')
-rw-r--r--src/H5B.c350
1 files changed, 181 insertions, 169 deletions
diff --git a/src/H5B.c b/src/H5B.c
index 7ccbc61..5bb6a35 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -100,7 +100,7 @@
#define BOUND(MIN,X,MAX) ((X)<(MIN)?(MIN):((X)>(MAX)?(MAX):(X)))
/* PRIVATE PROTOTYPES */
-static H5B_ins_t H5B_insert_helper(H5F_t *f, const haddr_t *addr,
+static H5B_ins_t H5B_insert_helper(H5F_t *f, haddr_t addr,
const H5B_class_t *type,
const double split_ratios[],
uint8_t *lt_key,
@@ -110,31 +110,28 @@ static H5B_ins_t H5B_insert_helper(H5F_t *f, const haddr_t *addr,
hbool_t *rt_key_changed,
haddr_t *retval);
static herr_t H5B_insert_child(H5F_t *f, const H5B_class_t *type,
- H5B_t *bt, intn idx,
- const haddr_t *child,
+ H5B_t *bt, intn idx, haddr_t child,
H5B_ins_t anchor, void *md_key);
-static herr_t H5B_flush(H5F_t *f, hbool_t destroy,
- const haddr_t *addr, H5B_t *b);
-static H5B_t *H5B_load(H5F_t *f, const haddr_t *addr,
- const void *_type, void *udata);
+static herr_t H5B_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5B_t *b);
+static H5B_t *H5B_load(H5F_t *f, haddr_t addr, const void *_type, void *udata);
static herr_t H5B_decode_key(H5F_t *f, H5B_t *bt, intn idx);
static herr_t H5B_decode_keys(H5F_t *f, H5B_t *bt, intn idx);
static size_t H5B_nodesize(H5F_t *f, const H5B_class_t *type,
size_t *total_nkey_size, size_t sizeof_rkey);
-static herr_t H5B_split(H5F_t *f, const H5B_class_t *type,
- H5B_t *old_bt, const haddr_t *old_addr, intn idx,
+static herr_t H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
+ haddr_t old_addr, intn idx,
const double split_ratios[], void *udata,
haddr_t *new_addr/*out*/);
#ifdef H5B_DEBUG
-static herr_t H5B_assert(H5F_t *f, const haddr_t *addr,
- const H5B_class_t *type, void *udata);
+static herr_t H5B_assert(H5F_t *f, haddr_t addr, const H5B_class_t *type,
+ void *udata);
#endif
/* H5B inherits cache-like properties from H5AC */
static const H5AC_class_t H5AC_BT[1] = {{
H5AC_BT_ID,
- (void *(*)(H5F_t*, const haddr_t*, const void*, void*))H5B_load,
- (herr_t (*)(H5F_t*, hbool_t, const haddr_t*, void*))H5B_flush,
+ (void *(*)(H5F_t*, haddr_t, const void*, void*))H5B_load,
+ (herr_t (*)(H5F_t*, hbool_t, haddr_t, void*))H5B_flush,
}};
/* Interface initialization? */
@@ -149,20 +146,25 @@ static intn interface_initialize_g = 0;
* passed as an argument to the sizeof_rkey() method for the
* B-tree.
*
- * Return: Non-negative on success (address of new node is returned
- * through the RETVAL argument.) /Negative on failure
+ * Return: Success: Non-negative, and the address of new node is
+ * returned through the ADDR_P argument.
+ *
+ * Failure: Negative
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Jun 23 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * Changed the name of the ADDR argument to ADDR_P to make it
+ * obvious that the address is passed by reference unlike most
+ * other functions that take addresses.
*-------------------------------------------------------------------------
*/
herr_t
H5B_create(H5F_t *f, const H5B_class_t *type, void *udata,
- haddr_t *addr/*out*/)
+ haddr_t *addr_p/*out*/)
{
H5B_t *bt = NULL;
size_t size, sizeof_rkey;
@@ -178,15 +180,15 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata,
*/
assert(f);
assert(type);
- assert(addr);
+ assert(addr_p);
/*
* Allocate file and memory data structures.
*/
sizeof_rkey = (type->get_sizeof_rkey) (f, udata);
size = H5B_nodesize(f, type, &total_native_keysize, sizeof_rkey);
- if (H5MF_alloc(f, H5MF_META, (hsize_t)size, addr/*out*/) < 0) {
- H5F_addr_undef (addr);
+ if (H5MF_alloc(f, H5MF_META, (hsize_t)size, addr_p/*out*/) < 0) {
+ H5F_addr_undef(addr_p);
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
"file allocation failed for B-tree root node");
}
@@ -236,18 +238,18 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata,
/*
* Cache the new B-tree node.
*/
- if (H5AC_set(f, H5AC_BT, addr, bt) < 0) {
+ if (H5AC_set(f, H5AC_BT, *addr_p, bt) < 0) {
HRETURN_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
"can't add B-tree root node to cache");
}
#ifdef H5B_DEBUG
- H5B_assert(f, addr, type, udata);
+ H5B_assert(f, *addr_p, type, udata);
#endif
ret_value = SUCCEED;
done:
if (ret_value<0) {
- H5MF_xfree (f, addr, (hsize_t)size);
+ H5MF_xfree (f, *addr_p, (hsize_t)size);
if (bt) {
H5MM_xfree (bt->page);
H5MM_xfree (bt->native);
@@ -275,11 +277,12 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata,
* Jun 23 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
static H5B_t *
-H5B_load(H5F_t *f, const haddr_t *addr, const void *_type, void *udata)
+H5B_load(H5F_t *f, haddr_t addr, const void *_type, void *udata)
{
const H5B_class_t *type = (const H5B_class_t *) _type;
size_t size, total_nkey_size;
@@ -292,7 +295,7 @@ H5B_load(H5F_t *f, const haddr_t *addr, const void *_type, void *udata)
/* Check arguments */
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(type);
assert(type->get_sizeof_rkey);
@@ -383,12 +386,15 @@ H5B_load(H5F_t *f, const haddr_t *addr, const void *_type, void *udata)
* Jun 23 1997
*
* Modifications:
- * rky 980828 Only p0 writes metadata to disk.
+ * rky 980828
+ * Only p0 writes metadata to disk.
*
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5B_t *bt)
+H5B_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5B_t *bt)
{
intn i;
size_t size = 0;
@@ -400,7 +406,7 @@ H5B_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5B_t *bt)
* Check arguments.
*/
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(bt);
assert(bt->type);
assert(bt->type->encode);
@@ -421,8 +427,8 @@ H5B_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5B_t *bt)
UINT16ENCODE(p, bt->nchildren);
/* sibling pointers */
- H5F_addr_encode(f, &p, &(bt->left));
- H5F_addr_encode(f, &p, &(bt->right));
+ H5F_addr_encode(f, &p, bt->left);
+ H5F_addr_encode(f, &p, bt->right);
/* child keys and pointers */
for (i=0; i<=bt->nchildren; i++) {
@@ -443,7 +449,7 @@ H5B_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5B_t *bt)
/* encode the child address */
if (i < bt->ndirty) {
- H5F_addr_encode(f, &p, &(bt->child[i]));
+ H5F_addr_encode(f, &p, bt->child[i]);
} else {
p += H5F_SIZEOF_ADDR(f);
}
@@ -498,11 +504,12 @@ H5B_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5B_t *bt)
* Jun 23 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5B_find(H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
+H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
{
H5B_t *bt = NULL;
intn idx = -1, lt = 0, rt, cmp = 1;
@@ -518,7 +525,7 @@ H5B_find(H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
assert(type->decode);
assert(type->cmp3);
assert(type->found);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
/*
* Perform a binary search to locate the child which contains
@@ -554,12 +561,12 @@ H5B_find(H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
*/
assert(idx >= 0 && idx < bt->nchildren);
if (bt->level > 0) {
- if ((ret_value = H5B_find(f, type, bt->child + idx, udata)) < 0) {
+ if ((ret_value = H5B_find(f, type, bt->child[idx], udata)) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL,
"key not found in subtree");
}
} else {
- ret_value = (type->found) (f, bt->child + idx, bt->key[idx].nkey,
+ ret_value = (type->found) (f, bt->child[idx], bt->key[idx].nkey,
udata, bt->key[idx+1].nkey);
if (ret_value < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL,
@@ -596,13 +603,15 @@ H5B_find(H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
* Jul 3 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The OLD_ADDR argument is passed by value. The NEW_ADDR
+ * argument has been renamed to NEW_ADDR_P
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
- const haddr_t *old_addr, intn idx, const double split_ratios[],
- void *udata, haddr_t *new_addr/*out*/)
+H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr,
+ intn idx, const double split_ratios[], void *udata,
+ haddr_t *new_addr_p/*out*/)
{
H5B_t *new_bt = NULL, *tmp_bt = NULL;
herr_t ret_value = FAIL;
@@ -616,7 +625,7 @@ H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
*/
assert(f);
assert(type);
- assert(old_addr && H5F_addr_defined(old_addr));
+ assert(H5F_addr_defined(old_addr));
/*
* Initialize variables.
@@ -628,12 +637,12 @@ H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
#ifdef H5B_DEBUG
if (H5DEBUG(B)) {
const char *side;
- if (!H5F_addr_defined(&(old_bt->left)) &&
- !H5F_addr_defined(&(old_bt->right))) {
+ if (!H5F_addr_defined(old_bt->left) &&
+ !H5F_addr_defined(old_bt->right)) {
side = "ONLY";
- } else if (!H5F_addr_defined(&(old_bt->right))) {
+ } else if (!H5F_addr_defined(old_bt->right)) {
side = "RIGHT";
- } else if (!H5F_addr_defined(&(old_bt->left))) {
+ } else if (!H5F_addr_defined(old_bt->left)) {
side = "LEFT";
} else {
side = "MIDDLE";
@@ -647,9 +656,9 @@ H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
* Decide how to split the children of the old node among the old node
* and the new node.
*/
- if (!H5F_addr_defined(&(old_bt->right))) {
+ if (!H5F_addr_defined(old_bt->right)) {
nleft = 2 * k * split_ratios[2]; /*right*/
- } else if (!H5F_addr_defined(&(old_bt->left))) {
+ } else if (!H5F_addr_defined(old_bt->left)) {
nleft = 2 * k * split_ratios[0]; /*left*/
} else {
nleft = 2 * k * split_ratios[1]; /*middle*/
@@ -675,11 +684,11 @@ H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
/*
* Create the new B-tree node.
*/
- if (H5B_create(f, type, udata, new_addr /*out */ ) < 0) {
+ if (H5B_create(f, type, udata, new_addr_p/*out*/) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
"unable to create B-tree");
}
- if (NULL == (new_bt = H5AC_protect(f, H5AC_BT, new_addr, type, udata))) {
+ if (NULL==(new_bt=H5AC_protect(f, H5AC_BT, *new_addr_p, type, udata))) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
"unable to protect B-tree");
}
@@ -718,25 +727,25 @@ H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
/*
* Update sibling pointers.
*/
- new_bt->left = *old_addr;
+ new_bt->left = old_addr;
new_bt->right = old_bt->right;
- if (H5F_addr_defined(&(old_bt->right))) {
- if (NULL == (tmp_bt = H5AC_find(f, H5AC_BT, &(old_bt->right), type,
+ if (H5F_addr_defined(old_bt->right)) {
+ if (NULL == (tmp_bt = H5AC_find(f, H5AC_BT, old_bt->right, type,
udata))) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
"unable to load right sibling");
}
tmp_bt->dirty = TRUE;
- tmp_bt->left = *new_addr;
+ tmp_bt->left = *new_addr_p;
}
- old_bt->right = *new_addr;
+ old_bt->right = *new_addr_p;
HGOTO_DONE(SUCCEED);
done:
{
- if (new_bt && H5AC_unprotect(f, H5AC_BT, new_addr, new_bt) < 0) {
+ if (new_bt && H5AC_unprotect(f, H5AC_BT, *new_addr_p, new_bt) < 0) {
HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, FAIL,
"unable to release B-tree node");
}
@@ -822,7 +831,6 @@ H5B_decode_keys(H5F_t *f, H5B_t *bt, intn idx)
* Jun 23 1997
*
* Modifications:
- *
* Robb Matzke, 28 Sep 1998
* The optional SPLIT_RATIOS[] indicates what percent of the child
* pointers should go in the left node when a node splits. There are
@@ -833,10 +841,12 @@ H5B_decode_keys(H5F_t *f, H5B_t *bt, intn idx)
* When a node is an only node at its level then we use the right-most
* rule. If SPLIT_RATIOS is null then default values are used.
*
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
+H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr,
const double split_ratios[], void *udata)
{
/*
@@ -864,7 +874,7 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
assert(f);
assert(type);
assert(type->sizeof_nkey <= sizeof _lt_key);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
if ((my_ins = H5B_insert_helper(f, addr, type, split_ratios, lt_key,
&lt_key_changed, md_key, udata, rt_key,
@@ -891,7 +901,7 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
}
/* the new node */
- if (NULL == (bt = H5AC_find(f, H5AC_BT, &child, type, udata))) {
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, child, type, udata))) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
"unable to load new node");
}
@@ -926,17 +936,17 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
HGOTO_ERROR(H5E_BTREE, H5E_READERROR, FAIL,
"unable to read B-tree root node");
}
- if (H5F_block_write(f, &old_root, (hsize_t)size, &H5F_xfer_dflt, buf)<0) {
+ if (H5F_block_write(f, old_root, (hsize_t)size, &H5F_xfer_dflt, buf)<0) {
HGOTO_ERROR(H5E_BTREE, H5E_WRITEERROR, FAIL,
"unable to move B-tree root node");
}
- if (H5AC_rename(f, H5AC_BT, addr, &old_root) < 0) {
+ if (H5AC_rename(f, H5AC_BT, addr, old_root) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL,
"unable to move B-tree root node");
}
/* update the new child's left pointer */
- if (NULL == (bt = H5AC_find(f, H5AC_BT, &child, type, udata))) {
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, child, type, udata))) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
"unable to load new child");
}
@@ -1002,20 +1012,19 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
* Jul 8 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The CHILD argument is passed by value.
*-------------------------------------------------------------------------
*/
static herr_t
H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt,
- intn idx, const haddr_t *child, H5B_ins_t anchor,
- void *md_key)
+ intn idx, haddr_t child, H5B_ins_t anchor, void *md_key)
{
size_t recsize;
intn i;
FUNC_ENTER(H5B_insert_child, FAIL);
assert(bt);
- assert(child);
assert(bt->nchildren<2*H5B_K(f, type));
bt->dirty = TRUE;
@@ -1078,7 +1087,7 @@ H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt,
bt->child + idx,
(bt->nchildren - idx) * sizeof(haddr_t));
- bt->child[idx] = *child;
+ bt->child[idx] = child;
bt->nchildren += 1;
bt->ndirty = bt->nchildren;
@@ -1102,7 +1111,7 @@ H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt,
*
* Return: Success: A B-tree operation. The address of the new
* node, if the node splits, is returned through
- * the NEW_NODE argument. The new node is always
+ * the NEW_NODE_P argument. The new node is always
* to the right of the previous node. This
* function is called recursively and the return
* value influences the behavior of the caller.
@@ -1126,14 +1135,17 @@ H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt,
* When a node is an only node at its level then we use the right-most
* rule. If SPLIT_RATIOS is null then default values are used.
*
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value. The NEW_NODE argument is
+ * renamed NEW_NODE_P
*-------------------------------------------------------------------------
*/
static H5B_ins_t
-H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
+H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
const double split_ratios[], uint8_t *lt_key,
hbool_t *lt_key_changed, uint8_t *md_key, void *udata,
uint8_t *rt_key, hbool_t *rt_key_changed,
- haddr_t *new_node/*out*/)
+ haddr_t *new_node_p/*out*/)
{
H5B_t *bt = NULL, *twin = NULL, *tmp_bt = NULL;
intn lt = 0, idx = -1, rt, cmp = -1;
@@ -1147,7 +1159,7 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
* Check arguments
*/
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(type);
assert(type->decode);
assert(type->cmp3);
@@ -1156,7 +1168,7 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
assert(lt_key_changed);
assert(rt_key);
assert(rt_key_changed);
- assert(new_node);
+ assert(new_node_p);
*lt_key_changed = FALSE;
*rt_key_changed = FALSE;
@@ -1194,8 +1206,8 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
assert(0 == bt->level);
bt->key[0].nkey = bt->native;
bt->key[1].nkey = bt->native + type->sizeof_nkey;
- if ((type->new_node) (f, H5B_INS_FIRST, bt->key[0].nkey, udata,
- bt->key[1].nkey, bt->child + 0/*out*/) < 0) {
+ if ((type->new_node)(f, H5B_INS_FIRST, bt->key[0].nkey, udata,
+ bt->key[1].nkey, bt->child + 0/*out*/) < 0) {
bt->key[0].nkey = bt->key[1].nkey = NULL;
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR,
"unable to create leaf node");
@@ -1208,10 +1220,10 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
idx = 0;
if (type->follow_min) {
- if ((my_ins = (type->insert) (f, bt->child+idx, bt->key[idx].nkey,
- lt_key_changed, md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/)) < 0) {
+ if ((my_ins = (type->insert)(f, bt->child[idx], bt->key[idx].nkey,
+ lt_key_changed, md_key, udata,
+ bt->key[idx+1].nkey, rt_key_changed,
+ &child_addr/*out*/)) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
"unable to insert first leaf node");
}
@@ -1229,7 +1241,7 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
"unable to decode key");
}
- if ((my_ins = H5B_insert_helper(f, bt->child+idx, type, split_ratios,
+ if ((my_ins = H5B_insert_helper(f, bt->child[idx], type, split_ratios,
bt->key[idx].nkey, lt_key_changed,
md_key, udata, bt->key[idx+1].nkey,
rt_key_changed,
@@ -1248,10 +1260,10 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
"unable to decode key");
}
- if ((my_ins = (type->insert) (f, bt->child+idx, bt->key[idx].nkey,
- lt_key_changed, md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/)) < 0) {
+ if ((my_ins = (type->insert)(f, bt->child[idx], bt->key[idx].nkey,
+ lt_key_changed, md_key, udata,
+ bt->key[idx+1].nkey, rt_key_changed,
+ &child_addr/*out*/)) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
"can't insert minimum leaf node");
}
@@ -1268,8 +1280,8 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
}
my_ins = H5B_INS_LEFT;
HDmemcpy(md_key, bt->key[idx].nkey, type->sizeof_nkey);
- if ((type->new_node) (f, H5B_INS_LEFT, bt->key[idx].nkey, udata,
- md_key, &child_addr/*out*/) < 0) {
+ if ((type->new_node)(f, H5B_INS_LEFT, bt->key[idx].nkey, udata,
+ md_key, &child_addr/*out*/) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
"can't insert minimum leaf node");
}
@@ -1285,7 +1297,7 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
"unable to decode key");
}
- if ((my_ins = H5B_insert_helper(f, bt->child+idx, type, split_ratios,
+ if ((my_ins = H5B_insert_helper(f, bt->child[idx], type, split_ratios,
bt->key[idx].nkey, lt_key_changed,
md_key, udata, bt->key[idx+1].nkey,
rt_key_changed,
@@ -1304,10 +1316,10 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
"unable to decode key");
}
- if ((my_ins = (type->insert) (f, bt->child+idx, bt->key[idx].nkey,
- lt_key_changed, md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/)) < 0) {
+ if ((my_ins = (type->insert)(f, bt->child[idx], bt->key[idx].nkey,
+ lt_key_changed, md_key, udata,
+ bt->key[idx+1].nkey, rt_key_changed,
+ &child_addr/*out*/)) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
"can't insert maximum leaf node");
}
@@ -1324,8 +1336,8 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
}
my_ins = H5B_INS_RIGHT;
HDmemcpy(md_key, bt->key[idx+1].nkey, type->sizeof_nkey);
- if ((type->new_node) (f, H5B_INS_RIGHT, md_key, udata,
- bt->key[idx+1].nkey, &child_addr/*out*/) < 0) {
+ if ((type->new_node)(f, H5B_INS_RIGHT, md_key, udata,
+ bt->key[idx+1].nkey, &child_addr/*out*/) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
"can't insert maximum leaf node");
}
@@ -1344,7 +1356,7 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
* Follow a branch out of this node to another subtree.
*/
assert(idx >= 0 && idx < bt->nchildren);
- if ((my_ins = H5B_insert_helper(f, bt->child+idx, type, split_ratios,
+ if ((my_ins = H5B_insert_helper(f, bt->child[idx], type, split_ratios,
bt->key[idx].nkey, lt_key_changed,
md_key, udata,
bt->key[idx+1].nkey, rt_key_changed,
@@ -1357,7 +1369,7 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
* Follow a branch out of this node to a leaf node of some other type.
*/
assert(idx >= 0 && idx < bt->nchildren);
- if ((my_ins = (type->insert) (f, bt->child+idx, bt->key[idx].nkey,
+ if ((my_ins = (type->insert)(f, bt->child[idx], bt->key[idx].nkey,
lt_key_changed, md_key, udata,
bt->key[idx+1].nkey, rt_key_changed,
&child_addr/*out*/)) < 0) {
@@ -1403,11 +1415,11 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
*/
if (bt->nchildren == 2 * H5B_K(f, type)) {
if (H5B_split(f, type, bt, addr, idx, split_ratios, udata,
- new_node/*out*/)<0) {
+ new_node_p/*out*/)<0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR,
"unable to split node");
}
- if (NULL == (twin = H5AC_protect(f, H5AC_BT, new_node, type,
+ if (NULL == (twin = H5AC_protect(f, H5AC_BT, *new_node_p, type,
udata))) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
"unable to load node");
@@ -1423,7 +1435,7 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
}
/* Insert the child */
- if (H5B_insert_child(f, type, tmp_bt, idx, &child_addr, my_ins,
+ if (H5B_insert_child(f, type, tmp_bt, idx, child_addr, my_ins,
md_key) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
"can't insert child");
@@ -1461,7 +1473,7 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
done:
{
herr_t e1 = (bt && H5AC_unprotect(f, H5AC_BT, addr, bt) < 0);
- herr_t e2 = (twin && H5AC_unprotect(f, H5AC_BT, new_node, twin) < 0);
+ herr_t e2 = (twin && H5AC_unprotect(f, H5AC_BT, *new_node_p, twin)<0);
if (e1 || e2) { /*use vars to prevent short-circuit of side effects */
HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR,
"unable to release node(s)");
@@ -1487,15 +1499,16 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
* Robb Matzke, 1999-04-21
* The key values are passed to the function which is called.
*
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5B_iterate (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
- void *udata)
+H5B_iterate (H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
{
H5B_t *bt = NULL;
haddr_t next_addr;
- const haddr_t *cur_addr = NULL;
+ haddr_t cur_addr = H5F_ADDR_UNDEF;
haddr_t *child = NULL;
uint8_t *key = NULL;
intn i, nchildren;
@@ -1509,7 +1522,7 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
assert(f);
assert(type);
assert(type->list);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(udata);
if (NULL == (bt=H5AC_find(f, H5AC_BT, addr, type, udata))) {
@@ -1518,7 +1531,7 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
}
if (bt->level > 0) {
/* Keep following the left-most child until we reach a leaf node. */
- if ((ret_value=H5B_iterate(f, type, bt->child+0, udata))<0) {
+ if ((ret_value=H5B_iterate(f, type, bt->child[0], udata))<0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL,
"unable to list B-tree node");
}
@@ -1534,7 +1547,7 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
}
for (cur_addr=addr, ret_value=0;
H5F_addr_defined(cur_addr);
- cur_addr=&next_addr) {
+ cur_addr=next_addr) {
/*
* Save all the child addresses and native keys since we can't
@@ -1562,7 +1575,7 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
*/
for (i=0, ret_value=0; i<nchildren && !ret_value; i++) {
ret_value = (type->list)(f, key+i*type->sizeof_nkey,
- child+i, key+(i+1)*type->sizeof_nkey,
+ child[i], key+(i+1)*type->sizeof_nkey,
udata);
if (ret_value<0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
@@ -1602,11 +1615,12 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
* Wednesday, September 16, 1998
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
static H5B_ins_t
-H5B_remove_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
+H5B_remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
intn level, uint8_t *lt_key/*out*/,
hbool_t *lt_key_changed/*out*/, void *udata,
uint8_t *rt_key/*out*/, hbool_t *rt_key_changed/*out*/)
@@ -1618,7 +1632,7 @@ H5B_remove_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
FUNC_ENTER(H5B_remove_helper, H5B_INS_ERROR);
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(type);
assert(type->decode);
assert(type->cmp3);
@@ -1662,7 +1676,7 @@ H5B_remove_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
if (bt->level>0) {
/* We're at an internal node -- call recursively */
if ((ret_value=H5B_remove_helper(f,
- bt->child+idx,
+ bt->child[idx],
type,
level+1,
bt->key[idx].nkey/*out*/,
@@ -1680,7 +1694,7 @@ H5B_remove_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
* object and let it decide how to progress.
*/
if ((ret_value=(type->remove)(f,
- bt->child+idx,
+ bt->child[idx],
bt->key[idx].nkey,
lt_key_changed,
udata,
@@ -1742,8 +1756,8 @@ H5B_remove_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
bt->nchildren = 0;
bt->ndirty = 0;
if (level>0) {
- if (H5F_addr_defined(&(bt->left))) {
- if (NULL==(sibling=H5AC_find(f, H5AC_BT, &(bt->left), type,
+ if (H5F_addr_defined(bt->left)) {
+ if (NULL==(sibling=H5AC_find(f, H5AC_BT, bt->left, type,
udata))) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
"unable to unlink node from tree");
@@ -1751,8 +1765,8 @@ H5B_remove_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
sibling->right = bt->right;
sibling->dirty = TRUE;
}
- if (H5F_addr_defined(&(bt->right))) {
- if (NULL==(sibling=H5AC_find(f, H5AC_BT, &(bt->right), type,
+ if (H5F_addr_defined(bt->right)) {
+ if (NULL==(sibling=H5AC_find(f, H5AC_BT, bt->right, type,
udata))) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
"unable to unlink node from tree");
@@ -1883,12 +1897,12 @@ H5B_remove_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
* Wednesday, September 16, 1998
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5B_remove(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
- void *udata)
+H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
{
/* These are defined this way to satisfy alignment constraints */
uint64_t _lt_key[128], _rt_key[128];
@@ -1905,7 +1919,7 @@ H5B_remove(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
assert(f);
assert(type);
assert(type->sizeof_nkey <= sizeof _lt_key);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
/* The actual removal */
if (H5B_remove_helper(f, addr, type, 0, lt_key, &lt_key_changed,
@@ -2002,12 +2016,13 @@ H5B_nodesize(H5F_t *f, const H5B_class_t *type,
* Aug 4 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5B_debug(H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
- intn fwidth, const H5B_class_t *type, void *udata)
+H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth,
+ const H5B_class_t *type, void *udata)
{
H5B_t *bt = NULL;
int i;
@@ -2018,7 +2033,7 @@ H5B_debug(H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
* Check arguments.
*/
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(stream);
assert(indent >= 0);
assert(fwidth >= 0);
@@ -2034,46 +2049,42 @@ H5B_debug(H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
/*
* Print the values.
*/
- fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Tree type ID:",
- (int) (bt->type->id));
- fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Size of raw (disk) key:",
- (unsigned long) (bt->sizeof_rkey));
- fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Dirty flag:",
- bt->dirty ? "True" : "False");
- fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Number of initial dirty children:",
- (int) (bt->ndirty));
- fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Level:",
- (int) (bt->level));
-
- fprintf(stream, "%*s%-*s ", indent, "", fwidth,
- "Address of left sibling:");
- H5F_addr_print(stream, &(bt->left));
- fprintf(stream, "\n");
-
- fprintf(stream, "%*s%-*s ", indent, "", fwidth,
- "Address of right sibling:");
- H5F_addr_print(stream, &(bt->right));
- fprintf(stream, "\n");
-
- fprintf(stream, "%*s%-*s %d (%d)\n", indent, "", fwidth,
- "Number of children (max):",
- (int) (bt->nchildren),
- (int) (2 * H5B_K(f, type)));
+ HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Tree type ID:",
+ (int) (bt->type->id));
+ HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Size of raw (disk) key:",
+ (unsigned long) (bt->sizeof_rkey));
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Dirty flag:",
+ bt->dirty ? "True" : "False");
+ HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Number of initial dirty children:",
+ (int) (bt->ndirty));
+ HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Level:",
+ (int) (bt->level));
+
+ HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
+ "Address of left sibling:",
+ bt->left);
+
+ HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
+ "Address of right sibling:",
+ bt->right);
+
+ HDfprintf(stream, "%*s%-*s %d (%d)\n", indent, "", fwidth,
+ "Number of children (max):",
+ (int) (bt->nchildren),
+ (int) (2 * H5B_K(f, type)));
/*
* Print the child addresses
*/
for (i = 0; i < bt->nchildren; i++) {
- fprintf(stream, "%*sChild %d...\n", indent, "", i);
- fprintf(stream, "%*s%-*s ", indent + 3, "", MAX(0, fwidth - 3),
- "Address:");
- H5F_addr_print(stream, bt->child + i);
- fprintf(stream, "\n");
+ HDfprintf(stream, "%*sChild %d...\n", indent, "", i);
+ HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3),
+ "Address:", bt->child[i]);
H5B_decode_key(f, bt, i);
if (type->debug_key) {
@@ -2084,6 +2095,7 @@ H5B_debug(H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5B_assert
@@ -2098,13 +2110,13 @@ H5B_debug(H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
* Tuesday, November 4, 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
#ifdef H5B_DEBUG
static herr_t
-H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
- void *udata)
+H5B_assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata)
{
H5B_t *bt = NULL;
intn i, ncell, cmp;
@@ -2131,7 +2143,7 @@ H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
assert(bt);
cur = H5MM_calloc(sizeof(struct child_t));
assert (cur);
- cur->addr = *addr;
+ cur->addr = addr;
cur->level = bt->level;
head = tail = cur;
@@ -2142,21 +2154,21 @@ H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
* test.
*/
for (ncell = 0; cur; ncell++) {
- bt = H5AC_protect(f, H5AC_BT, &(cur->addr), type, udata);
+ bt = H5AC_protect(f, H5AC_BT, cur->addr, type, udata);
assert(bt);
/* Check node header */
assert(bt->ndirty >= 0 && bt->ndirty <= bt->nchildren);
assert(bt->level == cur->level);
if (cur->next && cur->next->level == bt->level) {
- assert(H5F_addr_eq(&(bt->right), &(cur->next->addr)));
+ assert(H5F_addr_eq(bt->right, cur->next->addr));
} else {
- assert(!H5F_addr_defined(&(bt->right)));
+ assert(!H5F_addr_defined(bt->right));
}
if (prev && prev->level == bt->level) {
- assert(H5F_addr_eq(&(bt->left), &(prev->addr)));
+ assert(H5F_addr_eq(bt->left, prev->addr));
} else {
- assert(!H5F_addr_defined(&(bt->left)));
+ assert(!H5F_addr_defined(bt->left));
}
if (cur->level > 0) {
@@ -2167,7 +2179,7 @@ H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
* have then the tree has a cycle.
*/
for (tmp = head; tmp; tmp = tmp->next) {
- assert(H5F_addr_ne(&(tmp->addr), bt->child + i));
+ assert(H5F_addr_ne(tmp->addr, bt->child[i]));
}
/* Add the child node to the end of the queue */
@@ -2187,7 +2199,7 @@ H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
}
}
/* Release node */
- status = H5AC_unprotect(f, H5AC_BT, &(cur->addr), bt);
+ status = H5AC_unprotect(f, H5AC_BT, cur->addr, bt);
assert(status >= 0);
/* Advance current location in queue */