mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-29 22:08:45 +08:00
Merge remote-tracking branch 'origin/feature/memory_set_clear' into development
# Conflicts: # include/etl/memory.h # include/etl/version.h # support/Release notes.txt
This commit is contained in:
parent
2a3aa9fcee
commit
a8253b2a3f
@ -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 <typename T>
|
||||
void memory_clear(T &object)
|
||||
{
|
||||
std::fill_n(reinterpret_cast<char*>(&object),
|
||||
sizeof(T),
|
||||
0);
|
||||
memory_clear(reinterpret_cast<volatile char*>(&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 <typename T>
|
||||
void memory_set(T &object, int value)
|
||||
void memory_set(T &object, char value)
|
||||
{
|
||||
std::fill_n(reinterpret_cast<char*>(&object),
|
||||
sizeof(T),
|
||||
static_cast<char>(value));
|
||||
memory_set(reinterpret_cast<volatile char*>(&object), sizeof(T), value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user