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:
Andreas Kling 2021-01-10 15:55:54 +01:00
parent 70fce5c4c7
commit 2f3b901f7f
Notes: sideshowbarker 2024-07-18 23:57:45 +09:00
36 changed files with 184 additions and 199 deletions

View file

@ -36,14 +36,19 @@
namespace ELF {
Image::Image(const u8* buffer, size_t size, bool verbose_logging)
: m_buffer(buffer)
, m_size(size)
Image::Image(ReadonlyBytes bytes, bool verbose_logging)
: m_buffer(bytes.data())
, m_size(bytes.size())
, m_verbose_logging(verbose_logging)
{
parse();
}
Image::Image(const u8* buffer, size_t size, bool verbose_logging)
: Image(ReadonlyBytes { buffer, size }, verbose_logging)
{
}
Image::~Image()
{
}