mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 11:04:59 +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:
parent
c69035c630
commit
899cee8185
10 changed files with 31 additions and 72 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue