Lines Matching refs:root
68 lut_add(struct lut *root, const char *lhs, void *rhs) in lut_add() argument
72 if (root == NULL) { in lut_add()
74 root = MALLOC(sizeof (*root)); in lut_add()
75 root->lut_lhs = STRDUP(lhs); in lut_add()
76 root->lut_rhs = rhs; in lut_add()
77 root->lut_left = root->lut_right = NULL; in lut_add()
78 } else if (lhs != NULL && (diff = strcmp(root->lut_lhs, lhs)) == 0) { in lut_add()
80 root->lut_rhs = rhs; in lut_add()
82 root->lut_left = lut_add(root->lut_left, lhs, rhs); in lut_add()
84 root->lut_right = lut_add(root->lut_right, lhs, rhs); in lut_add()
85 return (root); in lut_add()
104 lut_dup(struct lut *root) in lut_dup() argument
108 lut_walk(root, dooper, &ret); in lut_dup()
117 lut_lookup(struct lut *root, const char *lhs) in lut_lookup() argument
121 if (root == NULL || lhs == NULL) in lut_lookup()
123 else if ((diff = strcmp(root->lut_lhs, lhs)) == 0) in lut_lookup()
124 return (root->lut_rhs); in lut_lookup()
126 return (lut_lookup(root->lut_left, lhs)); in lut_lookup()
128 return (lut_lookup(root->lut_right, lhs)); in lut_lookup()
135 lut_walk(struct lut *root, in lut_walk() argument
138 if (root) { in lut_walk()
139 lut_walk(root->lut_left, callback, arg); in lut_walk()
140 (*callback)(root->lut_lhs, root->lut_rhs, arg); in lut_walk()
141 lut_walk(root->lut_right, callback, arg); in lut_walk()
153 lut_free(struct lut *root, void (*callback)(void *rhs)) in lut_free() argument
155 if (root != NULL) { in lut_free()
156 lut_free(root->lut_left, callback); in lut_free()
157 lut_free(root->lut_right, callback); in lut_free()
158 FREE(root->lut_lhs); in lut_free()
160 (*callback)(root->lut_rhs); in lut_free()
161 FREE(root); in lut_free()