skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

avltree_newnode.c (393B)


      1 /* ISC license. */
      2 
      3 #include <errno.h>
      4 #include <skalibs/gensetdyn.h>
      5 #include <skalibs/avlnode.h>
      6 #include <skalibs/avltree.h>
      7 
      8 int avltree_newnode (avltree *t, uint32_t data, uint32_t *i)
      9 {
     10   if (!gensetdyn_new(&t->x, i)) return 0 ;
     11   {
     12     avlnode *s = avltree_nodes(t) ;
     13     s[*i].data = data ;
     14     s[*i].child[0] = s[*i].child[1] = UINT32_MAX ;
     15     s[*i].balance = 0 ;
     16   }
     17   return 1 ;
     18 }