Remove use of std::unique_ptr
The Hostboot user application has poor support for std::unique_ptr,
particularly using std::unique_ptr and std::map. Their implementation of
std::map does not have support for move-only objects like
std::unique_ptr. At this time it is much easier to change the current
use to std::shared_ptr. It is not as memory efficient, but will still
work. The memory impact is minimal since we only plan to used these
for each supported chip type, which we only have a few at this point.
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Ibed3e72f6f2c52fc044a442a2893fb07a3fa5d73
diff --git a/src/chip_data/hei_chip_data.cpp b/src/chip_data/hei_chip_data.cpp
index 3224f3f..847c0a5 100644
--- a/src/chip_data/hei_chip_data.cpp
+++ b/src/chip_data/hei_chip_data.cpp
@@ -400,7 +400,7 @@
HEI_ASSERT(VERSION_1 <= version && version <= VERSION_2);
// Allocate memory for the new isolation chip.
- auto isoChip = std::make_unique<IsolationChip>(chipType);
+ auto isoChip = std::make_shared<IsolationChip>(chipType);
// Read the register list metadata.
SectionKeyword_t regsKeyword;
@@ -458,7 +458,7 @@
HEI_ASSERT(stream.eof());
// Add this isolation chip to the collective list of isolation chips.
- auto ret = io_isoChips.emplace(chipType, std::move(isoChip));
+ auto ret = io_isoChips.emplace(chipType, isoChip);
HEI_ASSERT(ret.second); // Just in case.
}
diff --git a/src/isolator/hei_isolation_chip.hpp b/src/isolator/hei_isolation_chip.hpp
index a7badcb..7ba7346 100644
--- a/src/isolator/hei_isolation_chip.hpp
+++ b/src/isolator/hei_isolation_chip.hpp
@@ -31,8 +31,8 @@
class IsolationChip
{
public: // Aliases
- using Ptr = std::unique_ptr<IsolationChip>;
- using ConstPtr = std::unique_ptr<const IsolationChip>;
+ using Ptr = std::shared_ptr<IsolationChip>;
+ using ConstPtr = std::shared_ptr<const IsolationChip>;
using Map = std::map<ChipType_t, const ConstPtr>;