- /* strings with spaces are probably commands e.g. modprobe,
- with unique arguments. */
- if (strchr(str, ' ') != NULL)
- return add_new_string(rules, str, len + 1);
-
- /* descend root - start from last character of str */
- key = str[len - 1];
- node_off = rules->trie_root[key];
- depth = 0;
-
- /* descend suffix trie */
- if (node_off != 0) {
- while (1) {
- struct trie_node *node = &rules->trie[node_off];
- unsigned char child_slot;
-
- depth++;
- off = node->value_off + node->value_len - len;
-
- /* match against current node */
- if (depth == len ||
- (node->value_len >= len &&
- memcmp(&rules->buf[off], str, len) == 0))
- {
- return off;
- }
+ /* walk trie, start from last character of str to find matching tails */
+ node_idx = 0;
+ key = str[len-1];
+ for (depth = 0; depth <= len; depth++) {
+ struct trie_node *node;
+ unsigned int child_idx;