1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 23:32:06 +00:00

Kernel/SysFS: Prevent allocation for component name during construction

Instead, allocate before constructing the object and pass NonnullOwnPtr
of KString to the object if needed. Some classes can determine their
names as they have a known attribute to look for or have a static name.
This commit is contained in:
Liav A 2021-12-12 16:33:08 +02:00 committed by Andreas Kling
parent 4daf07e69f
commit 478f543899
17 changed files with 116 additions and 65 deletions

View file

@ -20,9 +20,8 @@ static size_t allocate_inode_index()
return s_next_inode_index.value();
}
SysFSComponent::SysFSComponent(StringView name)
: m_name(KString::try_create(name).release_value()) // FIXME: Handle KString allocation failure.
, m_component_index(allocate_inode_index())
SysFSComponent::SysFSComponent()
: m_component_index(allocate_inode_index())
{
}
@ -55,13 +54,8 @@ RefPtr<SysFSComponent> SysFSDirectory::lookup(StringView name)
return {};
}
SysFSDirectory::SysFSDirectory(StringView name)
: SysFSComponent(name)
{
}
SysFSDirectory::SysFSDirectory(StringView name, SysFSDirectory const& parent_directory)
: SysFSComponent(name)
SysFSDirectory::SysFSDirectory(SysFSDirectory const& parent_directory)
: SysFSComponent()
, m_parent_directory(parent_directory)
{
}