Add safety check that ZeroMemory is never called on a c++ complex class.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
7d7e46f7ec
commit
e638f63f6e
1 changed files with 8 additions and 1 deletions
|
@ -65,7 +65,14 @@
|
|||
#define FillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
|
||||
#define EqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
|
||||
#define CopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
|
||||
#define ZeroMemory(Destination,Length) memset((Destination),0,(Length))
|
||||
|
||||
template <typename T>
|
||||
void ZeroMemory(T * dest, const size_t size)
|
||||
{
|
||||
// never zero a C++ complex type requiring a constructor call.
|
||||
static_assert(std::is_pod<T>::value || std::is_void<T>::value, "POD required for ZeroMemory()");
|
||||
memset(dest, 0, size);
|
||||
}
|
||||
|
||||
void _tzset();
|
||||
errno_t ctime_s(char * buf, size_t size, const time_t *time);
|
||||
|
|
Loading…
Add table
Reference in a new issue