IPMIFruArea: use vector instead of raw byte pointer
Use vector of bytes instead of raw byte pointer.
Change-Id: I20a2beec3cbbc44c8cc3a48cefd73f3f27bdcc8f
Signed-off-by: Patrick Venture <venture@google.com>
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 @@
//-----------------------------------------------------
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 @@
//-------------------
IPMIFruArea::~IPMIFruArea()
{
- if (data != NULL)
- {
- delete[] data;
- data = NULL;
- }
}