From e4c6a69f776cd8056985ce56ba6528bd842a1ea8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Apr 2022 15:44:03 +0200 Subject: [PATCH] this should also zero-init the pool entries --- src/fsfw/datapool/PoolEntry.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/fsfw/datapool/PoolEntry.cpp b/src/fsfw/datapool/PoolEntry.cpp index d8e1d634..7e922bcb 100644 --- a/src/fsfw/datapool/PoolEntry.cpp +++ b/src/fsfw/datapool/PoolEntry.cpp @@ -8,17 +8,15 @@ template PoolEntry::PoolEntry(uint8_t len, bool setValid): length(len), valid(setValid) { - this->address = new T[this->length]; + this->address = new T[this->length](); std::memset(this->address, 0, this->getByteSize()); } template PoolEntry::PoolEntry(std::initializer_list initValues, bool setValid) : length(static_cast(initValues.size())), valid(setValid) { - this->address = new T[this->length]; - if (initValues.size() == 0) { - std::memset(this->address, 0, this->getByteSize()); - } else { + this->address = new T[this->length](); + if (initValues.size() > 0) { std::copy(initValues.begin(), initValues.end(), this->address); } } @@ -26,11 +24,9 @@ PoolEntry::PoolEntry(std::initializer_list initValues, bool setValid) template PoolEntry::PoolEntry(T* initValue, uint8_t setLength, bool setValid) : length(setLength), valid(setValid) { - this->address = new T[this->length]; + this->address = new T[this->length](); if (initValue != nullptr) { std::memcpy(this->address, initValue, this->getByteSize()); - } else { - std::memset(this->address, 0, this->getByteSize()); } }