diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2019-03-01 21:53:13 -0800 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2019-03-04 23:34:39 -0800 |
commit | 8ec4f46f31b1d2f71d193952e595e2037fe7f22d (patch) | |
tree | 3e94a9a405587319168ba58558cc1d1681dabb85 /eval.c | |
parent | b921fb2f43869ed12822ee99a80ccba9fd67c640 (diff) | |
download | bfs-8ec4f46f31b1d2f71d193952e595e2037fe7f22d.tar.xz |
trie: Revamp the API to support mappings
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -1147,14 +1147,17 @@ static bool eval_file_unique(struct eval_state *state, struct trie *seen) { memcpy(id, &statbuf->dev, sizeof(statbuf->dev)); memcpy(id + sizeof(statbuf->dev), &statbuf->ino, sizeof(statbuf->ino)); - int ret = trie_meminsert(seen, id, sizeof(id)); - if (ret > 0) { - state->action = BFTW_SKIP_SUBTREE; - return false; - } else if (ret < 0) { + struct trie_leaf *leaf = trie_insert_mem(seen, id, sizeof(id)); + if (!leaf) { eval_report_error(state); return false; + } + + if (leaf->value) { + state->action = BFTW_SKIP_SUBTREE; + return false; } else { + leaf->value = leaf; return true; } } |