Lines Matching defs:root
63 * struct lut *root = NULL;
64 * root = lut_add(root, "key", value);
70 lut_add(struct lut *root, const char *lhs, void *rhs)
74 if (root == NULL) {
76 root = MALLOC(sizeof (*root));
77 root->lut_lhs = STRDUP(lhs);
78 root->lut_rhs = rhs;
79 root->lut_left = root->lut_right = NULL;
80 } else if (lhs != NULL && (diff = strcmp(root->lut_lhs, lhs)) == 0) {
82 root->lut_rhs = rhs;
84 root->lut_left = lut_add(root->lut_left, lhs, rhs);
86 root->lut_right = lut_add(root->lut_right, lhs, rhs);
87 return (root);
106 lut_dup(struct lut *root)
110 lut_walk(root, dooper, &ret);
119 lut_lookup(struct lut *root, const char *lhs)
123 if (root == NULL || lhs == NULL)
125 else if ((diff = strcmp(root->lut_lhs, lhs)) == 0)
126 return (root->lut_rhs);
128 return (lut_lookup(root->lut_left, lhs));
130 return (lut_lookup(root->lut_right, lhs));
137 lut_walk(struct lut *root,
140 if (root) {
141 lut_walk(root->lut_left, callback, arg);
142 (*callback)(root->lut_lhs, root->lut_rhs, arg);
143 lut_walk(root->lut_right, callback, arg);
152 * lut_free(root, free);
155 lut_free(struct lut *root, void (*callback)(void *rhs))
157 if (root != NULL) {
158 lut_free(root->lut_left, callback);
159 lut_free(root->lut_right, callback);
160 FREE(root->lut_lhs);
162 (*callback)(root->lut_rhs);
163 FREE(root);
173 struct lut *root = (struct lut *)arg;