mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:07:34 +00:00
AK: Make MappedFile heap-allocated and ref-counted
Let's adapt this class a bit better to how it's actually being used. Instead of having valid/invalid states and storing an error in case it's invalid, a MappedFile is now always valid, and the factory function that creates it will return an OSError if mapping fails.
This commit is contained in:
parent
70fce5c4c7
commit
2f3b901f7f
36 changed files with 184 additions and 199 deletions
|
@ -83,8 +83,10 @@ public:
|
|||
const StringView get_programming_interface(u8 class_id, u8 subclass_id, u8 programming_interface_id) const;
|
||||
|
||||
private:
|
||||
Database(const StringView& file_name)
|
||||
: m_file(file_name) {};
|
||||
explicit Database(NonnullRefPtr<MappedFile> file)
|
||||
: m_file(move(file))
|
||||
{
|
||||
}
|
||||
|
||||
int init();
|
||||
|
||||
|
@ -94,7 +96,7 @@ private:
|
|||
ClassMode,
|
||||
};
|
||||
|
||||
MappedFile m_file {};
|
||||
NonnullRefPtr<MappedFile> m_file;
|
||||
StringView m_view {};
|
||||
HashMap<int, NonnullOwnPtr<Vendor>> m_vendors;
|
||||
HashMap<int, NonnullOwnPtr<Class>> m_classes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue