From a85565334708840dd44b849a91c1fa09b9038093 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 5 Feb 2025 13:29:05 -0500 Subject: trie: New trie_{get,set}_{str,mem}() functions --- src/mtab.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/mtab.c') diff --git a/src/mtab.c b/src/mtab.c index bf9fc53..4cbb9a6 100644 --- a/src/mtab.c +++ b/src/mtab.c @@ -256,10 +256,7 @@ static int bfs_mtab_fill_types(struct bfs_mtab *mtab) { continue; } - struct trie_leaf *leaf = trie_insert_mem(&mtab->types, &sb.dev, sizeof(sb.dev)); - if (leaf) { - leaf->value = mount->type; - } else { + if (trie_set_mem(&mtab->types, &sb.dev, sizeof(sb.dev), mount->type) != 0) { goto fail; } } @@ -282,9 +279,9 @@ const char *bfs_fstype(const struct bfs_mtab *mtab, const struct bfs_stat *statb } } - const struct trie_leaf *leaf = trie_find_mem(&mtab->types, &statbuf->dev, sizeof(statbuf->dev)); - if (leaf) { - return leaf->value; + const char *type = trie_get_mem(&mtab->types, &statbuf->dev, sizeof(statbuf->dev)); + if (type) { + return type; } else { return "unknown"; } -- cgit v1.2.3