this should also zero-init the pool entries

This commit is contained in:
Robin Müller 2022-04-04 15:44:03 +02:00
parent 761a0c9bac
commit e4c6a69f77
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -8,17 +8,15 @@
template <typename T>
PoolEntry<T>::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 <typename T>
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValues, bool setValid)
: length(static_cast<uint8_t>(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<T>::PoolEntry(std::initializer_list<T> initValues, bool setValid)
template <typename T>
PoolEntry<T>::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());
}
}