]> git.kaiwu.me - klib.git/commitdiff
kavl_find() gave wrong counts when equal
authorHeng Li <lh3@me.com>
Thu, 17 May 2018 21:43:47 +0000 (17:43 -0400)
committerHeng Li <lh3@me.com>
Thu, 17 May 2018 21:43:47 +0000 (17:43 -0400)
kavl.h

diff --git a/kavl.h b/kavl.h
index 393e0996d153cee7e47dd67c7bb0bc6cdca0d88e..d58bf9d917ef7cfdab585872849b1c9067b35027 100644 (file)
--- a/kavl.h
+++ b/kavl.h
@@ -90,7 +90,8 @@ int main(void) {
                                cnt += kavl_size_child(__head, p, 0) + 1; \
                                p = p->__head.p[1]; \
                        } else { \
-                               if (cnt_) *cnt_ = cnt + 1; \
+                               cnt += kavl_size_child(__head, p, 0) + 1; \
+                               if (cnt_) *cnt_ = cnt; \
                                return (__type*)p; \
                        } \
                } \