libavl: fix manpage example, minor improvement to code

This commit is contained in:
spew 2016-12-24 17:58:31 -06:00
parent 6187b862b7
commit ff384cbddc
2 changed files with 2 additions and 2 deletions

View file

@ -104,7 +104,7 @@ get(Avltree *t, char *key)
return h ? h->val : -1;
}
\fI\&...\fP
Avltree *t = avlcreate(AVL, nodecmp);
Avltree *t = avlcreate(nodecmp);
.EE
.SH SOURCE

View file

@ -75,7 +75,6 @@ insert(int (*cmp)(Avl*, Avl*), Avl *p, Avl **qp, Avl *k, Avl **oldp)
}
c = cmp(k, q);
c = c > 0 ? 1 : c < 0 ? -1: 0;
if(c == 0) {
*oldp = q;
*k = *q;
@ -86,6 +85,7 @@ insert(int (*cmp)(Avl*, Avl*), Avl *p, Avl **qp, Avl *k, Avl **oldp)
*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);