From db5e4f70f1da518ece62f02fcb27ac68ff9f87ee Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Mon, 18 May 2015 09:07:48 +0200 Subject: [PATCH] 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 --- repos/base-hw/src/core/include/page_slab.h | 5 ++--- .../src/core/include/spec/arm/short_translation_table.h | 5 ----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/repos/base-hw/src/core/include/page_slab.h b/repos/base-hw/src/core/include/page_slab.h index df945633c..0e0948e67 100644 --- a/repos/base-hw/src/core/include/page_slab.h +++ b/repos/base-hw/src/core/include/page_slab.h @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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(p); _b_list.insert(&b->list_elem); _free_slab_entries += SLABS_PER_BLOCK; _in_alloc = false; diff --git a/repos/base-hw/src/core/include/spec/arm/short_translation_table.h b/repos/base-hw/src/core/include/spec/arm/short_translation_table.h index 33b3ed774..7153b0015 100644 --- a/repos/base-hw/src/core/include/spec/arm/short_translation_table.h +++ b/repos/base-hw/src/core/include/spec/arm/short_translation_table.h @@ -456,11 +456,6 @@ class Genode::Translation_table public: - /** - * Placement new - */ - void * operator new (size_t, void * p) { return p; } - /** * Constructor */