mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-15 21:58:24 +00:00
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:
committed by
Christian Helmuth
parent
9591e6caee
commit
dc39a8db62
@ -51,9 +51,9 @@ Main::Main(Env &env) : heap(env.ram(), env.rm())
|
||||
|
||||
/* induce initial heap expansion to remove RM noise */
|
||||
if (1) {
|
||||
void *addr;
|
||||
heap.alloc(0x100000, &addr);
|
||||
heap.free(addr, 0);
|
||||
heap.try_alloc(0x100000).with_result(
|
||||
[&] (void *ptr) { heap.free(ptr, 0); },
|
||||
[&] (Allocator::Alloc_error) { });
|
||||
}
|
||||
|
||||
addr_t beg((addr_t)&blob_beg);
|
||||
|
Reference in New Issue
Block a user