mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
AK: Make Vector::try_* functions return ErrorOr<void>
Instead of signalling allocation failure with a bool return value (false), we now use ErrorOr<void> and return ENOMEM as appropriate. This allows us to use TRY() and MUST() with Vector. :^)
This commit is contained in:
parent
cd49f30bea
commit
88b6428c25
16 changed files with 98 additions and 152 deletions
|
@ -641,8 +641,7 @@ public:
|
|||
ErrorOr<void> try_clone(const Kernel::Process::OpenFileDescriptions& other)
|
||||
{
|
||||
SpinlockLocker lock_other(other.m_fds_lock);
|
||||
if (!try_resize(other.m_fds_metadatas.size()))
|
||||
return ENOMEM;
|
||||
TRY(try_resize(other.m_fds_metadatas.size()));
|
||||
|
||||
for (size_t i = 0; i < other.m_fds_metadatas.size(); ++i) {
|
||||
m_fds_metadatas[i] = other.m_fds_metadatas[i];
|
||||
|
@ -662,7 +661,7 @@ public:
|
|||
ErrorOr<ScopedDescriptionAllocation> allocate(int first_candidate_fd = 0);
|
||||
size_t open_count() const;
|
||||
|
||||
bool try_resize(size_t size) { return m_fds_metadatas.try_resize(size); }
|
||||
ErrorOr<void> try_resize(size_t size) { return m_fds_metadatas.try_resize(size); }
|
||||
|
||||
size_t max_open() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue