hw: replace 'placement new' with 'construct_at<>'

Placement new can be misleading, as we already overload the new operator
to construct objects via pointers to allocators. To prohibit any problems here,
and to use one consistent approach, we can explicitely construct the object
with the already available 'construct_at' template function.

Ref #1443
This commit is contained in:
Stefan Kalkowski 2015-05-18 09:07:48 +02:00 committed by Christian Helmuth
parent b8f178e647
commit db5e4f70f1
2 changed files with 2 additions and 8 deletions

View File

@ -18,6 +18,7 @@
#include <base/stdint.h>
#include <util/list.h>
#include <util/bit_allocator.h>
#include <util/construct_at.h>
#include <core_mem_alloc.h>
@ -73,8 +74,6 @@ class Genode::Page_slab : public Genode::Allocator
indices.free(off / SLAB_SIZE);
return true;
}
void * operator new (size_t, void * p) { return p; }
};
Slab_block _initial_sb __attribute__((aligned(1 << ALIGN_LOG2))); /*
@ -148,7 +147,7 @@ class Genode::Page_slab : public Genode::Allocator
ALIGN_LOG2).is_ok()) {
throw Out_of_memory();
}
Slab_block *b = new (p) Slab_block();
Slab_block *b = Genode::construct_at<Slab_block>(p);
_b_list.insert(&b->list_elem);
_free_slab_entries += SLABS_PER_BLOCK;
_in_alloc = false;

View File

@ -456,11 +456,6 @@ class Genode::Translation_table
public:
/**
* Placement new
*/
void * operator new (size_t, void * p) { return p; }
/**
* Constructor
*/