+ /* lookup child node */
+ key = str[len - 1 - depth];
+ child_slot = trie_child_slot(node, key);
+
+ if(child_slot == node->child_cur)
+ break;
+
+ node_off = node->child[child_slot];
+ }
+ }
+
+ /* string not found, add it */
+ off = add_new_string(rules, str, len + 1);
+
+ /* grow trie storage if needed */
+ if (rules->trie_cur >= rules->trie_max) {
+ struct trie_node *trie;
+ unsigned short add;
+
+ /* double the buffer size */
+ add = rules->trie_max;
+ if (add < 8)
+ add = 8;
+
+ trie = realloc(rules->trie, (rules->trie_max + add) * sizeof(struct trie_node));
+ if (trie == NULL)
+ return -1;
+ dbg(rules->udev, "extend string index nodes from %u to %u\n", rules->trie_max, rules->trie_max + add);
+ rules->trie = trie;
+ rules->trie_max += add;
+ }
+
+ /* insert new child node */
+ child_off = rules->trie_cur;
+ if (depth == 0) {
+ rules->trie_root[key] = child_off;
+ } else {
+ struct trie_node *parent = &rules->trie[node_off];
+ unsigned char child_slot = parent->child_cur;
+
+ /* no space in parent, we can't index this string, nevermind */
+ if (child_slot == TRIE_CHILD_MAX)
+ return off;
+
+ parent->child[child_slot] = child_off;
+ parent->child_key[child_slot] = key;
+ parent->child_cur = child_slot + 1;
+ }
+
+ /* allocate and construct the child node */
+ rules->trie_cur++;
+ child = &rules->trie[child_off];
+ memset(child, 0x00, sizeof(struct trie_node));
+ child->value_off = off;
+ child->value_len = len;
+
+ return off;
+}
+
+static int add_token(struct udev_rules *rules, struct token *token)
+{