diff --git a/datapool/PoolEntry.cpp b/datapool/PoolEntry.cpp index f2968c32..af5584d8 100644 --- a/datapool/PoolEntry.cpp +++ b/datapool/PoolEntry.cpp @@ -2,12 +2,13 @@ #include template -PoolEntry::PoolEntry( T* initValue, uint8_t set_length, uint8_t set_valid ) : length(set_length), valid(set_valid) { +PoolEntry::PoolEntry(std::initializer_list initValue, uint8_t set_length, uint8_t set_valid ) : length(set_length), valid(set_valid) { this->address = new T[this->length]; - if (initValue != NULL) { - memcpy(this->address, initValue, this->getByteSize() ); - } else { - memset(this->address, 0, this->getByteSize() ); + if(initValue.size() == 0) { + memset(this->address, 0, this->getByteSize()); + } + else { + memcpy(this->address, initValue.begin(), this->getByteSize()); } } diff --git a/datapool/PoolEntry.h b/datapool/PoolEntry.h index ce41a991..97364bf0 100644 --- a/datapool/PoolEntry.h +++ b/datapool/PoolEntry.h @@ -5,6 +5,7 @@ #include #include #include +#include /** * \brief This is a small helper class that defines a single data pool entry. * @@ -31,7 +32,7 @@ public: * \param set_length Defines the array length of this entry. * \param set_valid Sets the initialization flag. It is invalid (0) by default. */ - PoolEntry( T* initValue = NULL, uint8_t set_length = 1, uint8_t set_valid = 0 ); + PoolEntry( std::initializer_list initValue = {}, uint8_t set_length = 1, uint8_t set_valid = 0 ); /** * \brief The allocated memory for the variable is freed in the destructor. * \details As the data pool is global, this dtor is only called on program exit.