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;
-    }
 }
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 @@
     // Returns the length.
     size_t getLength() const
     {
-        return len;
+        return data.size();
     }
 
     // Returns the type of the current fru area
@@ -72,9 +72,9 @@
     }
 
     // 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 @@
     // 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 @@
     bool isValid = false;
 
     // Actual area data.
-    uint8_t* data = nullptr;
+    std::vector<uint8_t> data;
 
     // fru inventory dbus name
     std::string busName;