ref: ff384cbddc6ef8802c30d86ec147165b73441c26
parent: 6187b862b7d9ffc7baf3ed2fb2a203f1815a2e25
author: spew <devnull@localhost>
date: Sat Dec 24 12:58:31 EST 2016
libavl: fix manpage example, minor improvement to code
--- a/sys/man/2/avl
+++ b/sys/man/2/avl
@@ -104,7 +104,7 @@
return h ? h->val : -1;
}
\fI\&...\fP
- Avltree *t = avlcreate(AVL, nodecmp);
+ Avltree *t = avlcreate(nodecmp);
.EE
.SH SOURCE
--- a/sys/src/libavl/avl.c
+++ b/sys/src/libavl/avl.c
@@ -75,7 +75,6 @@
}
c = cmp(k, q);
- c = c > 0 ? 1 : c < 0 ? -1: 0;
if(c == 0) {
*oldp = q;
*k = *q;
@@ -86,6 +85,7 @@
*qp = k;
return 0;
}
+ c = c > 0 ? 1 : -1;
fix = insert(cmp, q, q->c + (c+1)/2, k, oldp);
if(fix)
return insertfix(c, qp);