1.1 --- a/libmem/lib/src/memory_preallocated.cc Mon Mar 21 00:17:42 2022 +0100
1.2 +++ b/libmem/lib/src/memory_preallocated.cc Tue Mar 22 23:03:44 2022 +0100
1.3 @@ -21,6 +21,8 @@
1.4
1.5 #include "memory_preallocated.h"
1.6
1.7 +#include <l4/cxx/exceptions>
1.8 +
1.9
1.10
1.11 /* Initialise the memory pool with the given amount in bytes. */
1.12 @@ -28,16 +30,16 @@
1.13 MemoryPreallocated::MemoryPreallocated(Memory *memory, offset_t amount)
1.14 : _memory(memory), _amount(amount)
1.15 {
1.16 - // NOTE: Handle allocation failure.
1.17 -
1.18 offset_t remaining = amount;
1.19
1.20 while (remaining)
1.21 {
1.22 - _regions.push_back(memory->region());
1.23 + Region *region = memory->region();
1.24
1.25 - if (memory->region_size() >= remaining)
1.26 - break;
1.27 + if (region == NULL)
1.28 + throw L4::Out_of_memory();
1.29 +
1.30 + _regions.push_back(region);
1.31
1.32 remaining -= memory->region_size();
1.33 }