From f0f1ab9f94c58cdddae3c5036c1cbc6a95a7016d Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Sun, 21 Oct 2018 13:03:01 -0700 Subject: 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 --- fru_area.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'fru_area.cpp') 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; - } } -- cgit v1.2.1