summaryrefslogtreecommitdiffstats
path: root/src/H5TB.c
diff options
context:
space:
mode:
authorJohn Mainzer <mainzer@hdfgroup.org>2004-04-19 16:24:48 (GMT)
committerJohn Mainzer <mainzer@hdfgroup.org>2004-04-19 16:24:48 (GMT)
commit9937495a335e0c36a096bbbc7eee0b5d333e5731 (patch)
tree45fea8bf67094d3d04ea08199f2972ed2cbd12a1 /src/H5TB.c
parentd8a499cd874170d95e1c034e62533b58693e349c (diff)
downloadhdf5-9937495a335e0c36a096bbbc7eee0b5d333e5731.zip
hdf5-9937495a335e0c36a096bbbc7eee0b5d333e5731.tar.gz
hdf5-9937495a335e0c36a096bbbc7eee0b5d333e5731.tar.bz2
[svn-r8389] Purpose: Bug fix and warning
Description: Fixed bug in H5TB_less(). It was returning the next largest node, instead of the next smallest as advertised. Added comments warning that H5TB_rem()s will occasionally delete a node other than the one provided in its argument list. Solution: It was sufficient t invert two comparisons in H5TB_less(). Platforms tested: h5committested
Diffstat (limited to 'src/H5TB.c')
-rw-r--r--src/H5TB.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/H5TB.c b/src/H5TB.c
index 7b3e3f2..00eadc1 100644
--- a/src/H5TB.c
+++ b/src/H5TB.c
@@ -12,6 +12,19 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* WARNING!!!
+ *
+ * The function H5TB_rem() may not delete the node specified in its parameter
+ * list -- if the target node is internal, it may swap data with a leaf node
+ * and delete the leaf instead.
+ *
+ * This implies that any pointer to a node in the supplied tree may be
+ * invalid after this functions returns. Thus any function retaining such
+ * pointers over a call to H5TB_rem() should either discard, or refresh them.
+ *
+ * JRM - 4/9/04
+ */
+
/*
* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
* Saturday, April 22, 2000
@@ -550,6 +563,9 @@ done:
* Thursday, May 5, 2000
*
* Modifications:
+ * Fixed function so it seems to perform as advertized. Two
+ * tests were inverted in the backtrack case.
+ * JRM - 4/13/04
*
* Notes:
*
@@ -582,10 +598,10 @@ H5TB_less(H5TB_NODE * root, void * key, H5TB_cmp_t compar, int arg, H5TB_NODE **
if(cmp!=0) {
/* If we haven't already found the least node, then backtrack to
* find it */
- if(cmp>0) {
+ if(cmp<0) {
while((ptr=ptr->Parent)!=NULL) {
cmp = KEYcmp(key, ptr->key, arg);
- if(cmp<0) /* found a node which is less than the search for one */
+ if(cmp>0) /* found a node which is less than the search for one */
break;
} /* end while */
} /* end if */
@@ -805,6 +821,19 @@ done:
* Modifications:
*
* Notes:
+ *
+ * WARNING!!!
+ *
+ * H5TB_rem() may not delete the node specified in its parameter
+ * list -- if the target node is internal, it may swap data with a
+ * leaf node and delete the leaf instead.
+ *
+ * This implies that any pointer to a node in the supplied tree may be
+ * invalid after this functions returns. Thus any function retaining
+ * such pointers over a call to H5TB_rem() should either discard, or
+ * refresh them.
+ *
+ * JRM - 4/9/04
*
*-------------------------------------------------------------------------
*/