From 3b2d3fb3fb9a2f0be42faea6a4883ffcdc463249 Mon Sep 17 00:00:00 2001 From: Niklas Eiling Date: Wed, 4 Jan 2023 10:32:36 +0100 Subject: [PATCH] Revert "villas/memory: make MemoryBlock use shared_ptr instead of unique_ptr" Instead, we want to rework the Memory handling entirely. This reverts commit c8128db732b0b01a418f26a0a54a2464fe1d09e6. Signed-off-by: Niklas Eiling --- common/include/villas/memory.hpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/common/include/villas/memory.hpp b/common/include/villas/memory.hpp index b4c3497a0..7ce425e70 100644 --- a/common/include/villas/memory.hpp +++ b/common/include/villas/memory.hpp @@ -76,12 +76,6 @@ public: memoryBlock(std::move(mem)) { } - // Take ownership of the MemoryBlock - MemoryAccessor(std::shared_ptr mem) : - translation(MemoryManager::get().getTranslationFromProcess(mem->getAddrSpaceId())), - memoryBlock(std::move(mem)) - { } - // Just act as an accessor, do not take ownership of MemoryBlock MemoryAccessor(const MemoryBlock &mem) : translation(MemoryManager::get().getTranslationFromProcess(mem.getAddrSpaceId())) @@ -112,10 +106,10 @@ public: return reinterpret_cast(translation.getLocalAddr(0)); } - const std::shared_ptr + const MemoryBlock& getMemoryBlock() const { - if (not memoryBlock) throw std::bad_alloc(); else return memoryBlock; + if (not memoryBlock) throw std::bad_alloc(); else return *memoryBlock; } private: @@ -123,7 +117,7 @@ private: MemoryTranslation translation; // Take the unique pointer in case user wants this class to have ownership - std::shared_ptr memoryBlock; + std::unique_ptr memoryBlock; }; /**