mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:47:34 +00:00
AK+Kernel: OOM-harden most parts of Trie
The only part of Unveil that can't handle OOM gracefully is the String::formatted() use in the node metadata.
This commit is contained in:
parent
80e6198563
commit
a1cb2c371a
9 changed files with 145 additions and 99 deletions
|
@ -24,9 +24,29 @@ enum UnveilAccess {
|
|||
struct UnveilNode;
|
||||
|
||||
struct UnveilMetadata {
|
||||
String full_path;
|
||||
NonnullOwnPtr<KString> full_path;
|
||||
UnveilAccess permissions { None };
|
||||
bool explicitly_unveiled { false };
|
||||
|
||||
UnveilMetadata(UnveilMetadata const&) = delete;
|
||||
UnveilMetadata(UnveilMetadata&&) = default;
|
||||
|
||||
// Note: Intentionally not explicit.
|
||||
UnveilMetadata(NonnullOwnPtr<KString>&& full_path, UnveilAccess permissions = None, bool explicitly_unveiled = false)
|
||||
: full_path(move(full_path))
|
||||
, permissions(permissions)
|
||||
, explicitly_unveiled(explicitly_unveiled)
|
||||
{
|
||||
}
|
||||
|
||||
ErrorOr<UnveilMetadata> copy() const
|
||||
{
|
||||
return UnveilMetadata {
|
||||
TRY(full_path->try_clone()),
|
||||
permissions,
|
||||
explicitly_unveiled,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
struct UnveilNode final : public Trie<String, UnveilMetadata, Traits<String>, UnveilNode> {
|
||||
|
@ -34,7 +54,7 @@ struct UnveilNode final : public Trie<String, UnveilMetadata, Traits<String>, Un
|
|||
|
||||
bool was_explicitly_unveiled() const { return this->metadata_value().explicitly_unveiled; }
|
||||
UnveilAccess permissions() const { return this->metadata_value().permissions; }
|
||||
const String& path() const { return this->metadata_value().full_path; }
|
||||
StringView path() const { return this->metadata_value().full_path->view(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue