mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
Kernel: Make KBuffer::try_create_with_size() return KResultOr
This allows us to use TRY() in a lot of new places.
This commit is contained in:
@@ -117,22 +117,13 @@ BlockBasedFileSystem::~BlockBasedFileSystem()
|
||||
KResult BlockBasedFileSystem::initialize()
|
||||
{
|
||||
VERIFY(block_size() != 0);
|
||||
auto cached_block_data = KBuffer::try_create_with_size(DiskCache::EntryCount * block_size());
|
||||
if (!cached_block_data)
|
||||
return ENOMEM;
|
||||
|
||||
auto entries_data = KBuffer::try_create_with_size(DiskCache::EntryCount * sizeof(CacheEntry));
|
||||
if (!entries_data)
|
||||
return ENOMEM;
|
||||
|
||||
auto disk_cache = adopt_own_if_nonnull(new (nothrow) DiskCache(*this, cached_block_data.release_nonnull(), entries_data.release_nonnull()));
|
||||
if (!disk_cache)
|
||||
return ENOMEM;
|
||||
auto cached_block_data = TRY(KBuffer::try_create_with_size(DiskCache::EntryCount * block_size()));
|
||||
auto entries_data = TRY(KBuffer::try_create_with_size(DiskCache::EntryCount * sizeof(CacheEntry)));
|
||||
auto disk_cache = TRY(adopt_nonnull_own_or_enomem(new (nothrow) DiskCache(*this, move(cached_block_data), move(entries_data))));
|
||||
|
||||
m_cache.with_exclusive([&](auto& cache) {
|
||||
cache = move(disk_cache);
|
||||
});
|
||||
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user