summaryrefslogtreecommitdiffstats
path: root/fru_area.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-10-21 13:03:01 -0700
committerPatrick Venture <venture@google.com>2018-10-30 08:28:31 -0700
commitf0f1ab9f94c58cdddae3c5036c1cbc6a95a7016d (patch)
treeab1a44642c9024e0945c70b6597ff987121d8674 /fru_area.cpp
parent740d8c00d3947dccb08611545f49da2bc5094189 (diff)
downloadipmi-fru-parser-f0f1ab9f94c58cdddae3c5036c1cbc6a95a7016d.zip
ipmi-fru-parser-f0f1ab9f94c58cdddae3c5036c1cbc6a95a7016d.tar.gz
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>
Diffstat (limited to 'fru_area.cpp')
-rw-r--r--fru_area.cpp10
1 files changed, 2 insertions, 8 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;
- }
}
OpenPOWER on IntegriCloud