Lines Matching refs:rootp
48 * rootp: Address of the root of the tree
52 tsearch(POINTER key, NODE **rootp, int (*compar)(POINTER, POINTER))
56 if (rootp == NULL)
58 while (*rootp != NULL) { /* T1: */
59 int r = (*compar)(key, (*rootp)->key); /* T2: */
61 return (*rootp); /* Key found */
62 rootp = (r < 0) ?
63 &(*rootp)->llink : /* T3: Take left branch */
64 &(*rootp)->rlink; /* T4: Take right branch */
68 *rootp = q; /* Link new node to old */
80 * rootp: Address of the root of tree
84 tdelete(POINTER key, NODE **rootp, int (*compar)(POINTER, POINTER))
91 if (rootp == NULL || (p = *rootp) == NULL)
93 while ((ans = (*compar)(key, (*rootp)->key)) != 0) {
94 p = *rootp;
95 rootp = (ans < 0) ?
96 &(*rootp)->llink : /* Take left branch */
97 &(*rootp)->rlink; /* Take right branch */
98 if (*rootp == NULL)
101 r = (*rootp)->rlink; /* D1: */
102 if ((q = (*rootp)->llink) == NULL) /* Llink NULL? */
112 q->llink = (*rootp)->llink;
113 q->rlink = (*rootp)->rlink;
116 free((POINTER) *rootp); /* D4: Free node */
117 *rootp = q; /* Link parent to replacement */