diff --git a/include/etl/memory.h b/include/etl/memory.h index 4bdd43e4..69af6ed9 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -1108,31 +1108,57 @@ namespace etl //***************************************************************************** /// A low level function that clears an object's memory to zero. - ///\tparam T The type. - ///\param object The object to clear. + + ///\param p Pointer to the memory. + ///\param n Size of the memory. + ///\ingroup memory + //***************************************************************************** + inline void memory_clear(volatile char* p, size_t n) + { + while (n--) + { + *p++ = 0; + } + } + + //***************************************************************************** + /// A low level function that clears an object's memory to zero. + ///\tparam T The type. + ///\param object The object to clear. ///\ingroup memory //***************************************************************************** template void memory_clear(T &object) { - std::fill_n(reinterpret_cast(&object), - sizeof(T), - 0); + memory_clear(reinterpret_cast(&object), sizeof(T)); + } + + //***************************************************************************** + /// A low level function that clears an object's memory to zero. + ///\param p Pointer to the memory. + ///\param n Size of the memory. + ///\param value The value to set. + ///\ingroup memory + //***************************************************************************** + inline void memory_set(volatile char* p, size_t n, char value) + { + while (n--) + { + *p++ = value; + } } //***************************************************************************** /// A low level function that sets an object's memory to a value. ///\tparam T The type. - ///\param object The object to set. - ///\param value The value to set the object with. + ///\param object The object to set. + ///\param value The value to set the object's memory to. ///\ingroup memory //***************************************************************************** template - void memory_set(T &object, int value) + void memory_set(T &object, char value) { - std::fill_n(reinterpret_cast(&object), - sizeof(T), - static_cast(value)); + memory_set(reinterpret_cast(&object), sizeof(T), value); } } diff --git a/include/etl/version.h b/include/etl/version.h index 3bc191e9..ab365918 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 14 #define ETL_VERSION_MINOR 22 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) ETL_STRINGIFY(ETL_VERSION_MINOR) ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_WIDE_STRING(ETL_CONCAT(ETL_CONCAT(ETL_VERSION_MAJOR, ETL_VERSION_MINOR), ETL_VERSION_PATCH)) diff --git a/support/Release notes.txt b/support/Release notes.txt index 40daab67..e4201fa2 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +14.22.1 +Modified memory functions so that they will not be optimised away. + =============================================================================== 14.22.0 Added etl::memory_clear and etl::memory_set utility functions.