base: introduce Allocator::try_alloc

This patch changes the 'Allocator' interface to the use of 'Attempt'
return values instead of using exceptions for propagating errors.

To largely uphold compatibility with components using the original
exception-based interface - in particluar use cases where an 'Allocator'
is passed to the 'new' operator - the traditional 'alloc' is still
supported. But it existes merely as a wrapper around the new
'try_alloc'.

Issue #4324
This commit is contained in:
Norman Feske
2021-11-10 12:01:32 +01:00
committed by Christian Helmuth
parent 9591e6caee
commit dc39a8db62
102 changed files with 2128 additions and 1710 deletions

View File

@ -410,11 +410,7 @@ namespace {
{
typedef Genode::size_t size_t;
bool alloc(size_t size, void **out_addr) override
{
*out_addr = malloc(size);
return true;
}
Alloc_result try_alloc(size_t size) override { return malloc(size); }
void free(void *addr, size_t) override { ::free(addr); }