mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-15 23:52:57 +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
Notes:
sideshowbarker
2024-07-18 23:57:45 +09:00
Author: https://github.com/awesomekling
Commit: 2f3b901f7f
36 changed files with 184 additions and 199 deletions
|
@ -57,11 +57,12 @@ static const ELFObjectInfo* object_info_for_region(const ELF::Core::MemoryRegion
|
|||
if (!Core::File::exists(path.characters()))
|
||||
return nullptr;
|
||||
|
||||
MappedFile object_file(path);
|
||||
if (!object_file.is_valid())
|
||||
auto file_or_error = MappedFile::map(path);
|
||||
if (file_or_error.is_error())
|
||||
return nullptr;
|
||||
|
||||
auto info = make<ELFObjectInfo>(move(object_file), Debug::DebugInfo { make<ELF::Image>((const u8*)object_file.data(), object_file.size()) });
|
||||
auto image = make<ELF::Image>(file_or_error.value()->bytes());
|
||||
auto info = make<ELFObjectInfo>(file_or_error.release_value(), Debug::DebugInfo { move(image) });
|
||||
auto* info_ptr = info.ptr();
|
||||
s_debug_info_cache.set(path, move(info));
|
||||
return info_ptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue