summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fru_area.cpp10
-rw-r--r--fru_area.hpp11
2 files changed, 6 insertions, 15 deletions
diff --git a/fru_area.cpp b/fru_area.cpp
index b5d8960..45d4008 100644
--- a/fru_area.cpp
+++ b/fru_area.cpp
@@ -49,9 +49,8 @@ IPMIFruArea::IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type,
//-----------------------------------------------------
void IPMIFruArea::setData(const uint8_t* value, const size_t length)
{
- len = length;
- data = new uint8_t[len];
- std::memcpy(data, value, len);
+ data.reserve(length); // pre-allocate the space.
+ data.insert(data.begin(), value, value + length);
}
//-----------------------------------------------------
@@ -70,9 +69,4 @@ void IPMIFruArea::updateDbusPaths(const char* bus, const char* path,
//-------------------
IPMIFruArea::~IPMIFruArea()
{
- if (data != NULL)
- {
- delete[] data;
- data = NULL;
- }
}
diff --git a/fru_area.hpp b/fru_area.hpp
index 28d50be..5294be2 100644
--- a/fru_area.hpp
+++ b/fru_area.hpp
@@ -38,7 +38,7 @@ class IPMIFruArea
// Returns the length.
size_t getLength() const
{
- return len;
+ return data.size();
}
// Returns the type of the current fru area
@@ -72,9 +72,9 @@ class IPMIFruArea
}
// Returns the data portion
- inline uint8_t* getData() const
+ inline const uint8_t* getData() const
{
- return data;
+ return data.data();
}
// Accepts a pointer to data and sets it in the object.
@@ -93,9 +93,6 @@ class IPMIFruArea
// Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
std::string name;
- // Length of a specific fru area.
- size_t len = 0;
-
// Special bit for BMC readable eeprom only.
bool bmcOnlyFru = false;
@@ -106,7 +103,7 @@ class IPMIFruArea
bool isValid = false;
// Actual area data.
- uint8_t* data = nullptr;
+ std::vector<uint8_t> data;
// fru inventory dbus name
std::string busName;
OpenPOWER on IntegriCloud