avltreen_delete.c (491B)
1 /* ISC license. */ 2 3 #include <stdint.h> 4 #include <errno.h> 5 #include <skalibs/genset.h> 6 #include <skalibs/avlnode.h> 7 #include <skalibs/avltreen.h> 8 9 int avltreen_delete (avltreen *t, void const *k) 10 { 11 uint32_t r = avltreen_root(t) ; 12 uint32_t i = avlnode_delete(avltreen_nodes(t), avltreen_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ; 13 if (i >= avltreen_totalsize(t)) return (errno = ESRCH, 0) ; 14 avltreen_setroot(t, r) ; 15 if (!genset_delete(&t->x, i)) return 0 ; 16 return 1 ; 17 }