mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-25 21:39:48 +00:00
The new types in base/ram.h model different allocation scenarios and error cases by mere C++ types without using exceptions. They are meant to replace the former 'Ram_allocator' interface. As of now, the 'Unmapped_allocator' closely captures the former 'Ram_allocator' semantics. The 'Constrained_allocator' is currently an alias for 'Unmapped_allocator' but is designated for eventually allocating mapped RAM. In contrast to the 'Ram_allocator' interface, which talked about dataspace capabilites but left the lifetime management of the allocated RAM to the caller, the new API represents an allocation as a guard type 'Allocation', which deallocates on destruction by default. Allocation errors are captured by a 'Result' type that follows the 'Attempt' pattern. As a transitionary feature, the patch largely maintains API compatibility with the original 'Ram_allocator' by providing the original (exception-based) 'Ram_allocator::alloc' and 'Ram_allocator::free' methods as a wrapper around the new 'Ram::Constrained_allocator'. So components can be gradually updated to the new 'Ram::' interface. Issue #5502