summaryrefslogtreecommitdiffstats
path: root/src/H5TB.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5TB.c')
-rw-r--r--src/H5TB.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/H5TB.c b/src/H5TB.c
index be5952f..be1b1aa 100644
--- a/src/H5TB.c
+++ b/src/H5TB.c
@@ -580,11 +580,15 @@ H5TB_less(H5TB_NODE * root, void * key, H5TB_cmp_t compar, int arg, H5TB_NODE **
/* didn't find an exact match, search back up the tree until a node */
/* is found with a key less than the key searched for */
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 */
- break;
- } /* end while */
+ /* If we haven't already found the least node, then backtrack to
+ * find it */
+ 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 */
+ break;
+ } /* end while */
+ } /* end if */
if(ptr==NULL) /* didn't find a node in the tree which was less */
cmp=1;
else /* reset this for cmp test below */