Skip to content

Commit f94f461

Browse files
atopiachelmuth
authored andcommitted
base: make Ram_allocator noncopyable
Prevent erratic runtime behavior stemming from accidentally passing a copy to a `Ram_allocator` by making the interface noncopyable. In consequence, we had to provide an explicit copy constructor for `Session_env` in server/nic_router, which will be reconsidered in issue #5405. Issue #5221
1 parent dd64164 commit f94f461

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

repos/base/include/base/ram_allocator.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <base/quota_guard.h>
2020
#include <base/cache.h>
2121
#include <dataspace/dataspace.h>
22+
#include <util/noncopyable.h>
2223

2324
namespace Genode {
2425

@@ -32,7 +33,7 @@ namespace Genode {
3233
}
3334

3435

35-
struct Genode::Ram_allocator : Interface
36+
struct Genode::Ram_allocator : Interface, Noncopyable
3637
{
3738
enum class Alloc_error { OUT_OF_RAM, OUT_OF_CAPS, DENIED };
3839

repos/os/src/server/nic_router/session_env.h

+12
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ class Genode::Session_env : public Ram_allocator,
104104
_cap_guard { cap_quota }
105105
{ }
106106

107+
/*
108+
* The Ram_allocator interface is Noncopyable, but this
109+
* implementation is safe to copy.
110+
*/
111+
Session_env(Session_env const &session)
112+
:
113+
_env { session._env },
114+
_shared_quota { session._shared_quota },
115+
_ram_guard { session._ram_guard },
116+
_cap_guard { session._cap_guard }
117+
{ }
118+
107119
Entrypoint &ep() { return _env.ep(); }
108120

109121

0 commit comments

Comments
 (0)