summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2019-03-01 21:53:13 -0800
committerTavian Barnes <tavianator@tavianator.com>2019-03-04 23:34:39 -0800
commit8ec4f46f31b1d2f71d193952e595e2037fe7f22d (patch)
tree3e94a9a405587319168ba58558cc1d1681dabb85 /eval.c
parentb921fb2f43869ed12822ee99a80ccba9fd67c640 (diff)
downloadbfs-8ec4f46f31b1d2f71d193952e595e2037fe7f22d.tar.xz
trie: Revamp the API to support mappings
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index 432adfc..d4097ef 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
}
}