9 #ifndef CPPCOMMON_MEMORY_MEMORY_H
10 #define CPPCOMMON_MEMORY_MEMORY_H
53 static bool IsZero(
const void* buffer,
size_t size) noexcept;
69 static bool IsAligned(
const T* address,
size_t alignment =
alignof(T)) noexcept;
79 static T*
Align(
const T* address,
size_t alignment =
alignof(T),
bool upwards =
true) noexcept;
86 static
void ZeroFill(
void* buffer,
size_t size);
92 static
void RandomFill(
void* buffer,
size_t size);
98 static
void CryptoFill(
void* buffer,
size_t size);
105 #include "memory.inl"
Memory management static class.
static bool IsZero(const void *buffer, size_t size) noexcept
Is the given memory buffer filled with zeros?
static bool IsValidAlignment(size_t alignment) noexcept
Is the given alignment valid?
static void CryptoFill(void *buffer, size_t size)
Fill the given memory buffer with cryptographic strong random bytes.
static int64_t RamFree()
Free RAM in bytes.
static bool IsAligned(const T *address, size_t alignment=alignof(T)) noexcept
Is the given pointer aligned?
Memory(const Memory &)=delete
Memory & operator=(Memory &&)=delete
static int64_t RamTotal()
Total RAM in bytes.
static T * Align(const T *address, size_t alignment=alignof(T), bool upwards=true) noexcept
Align pointer (upwards or downwards)
Memory & operator=(const Memory &)=delete
static void ZeroFill(void *buffer, size_t size)
Fill the given memory buffer with zeros.
static void RandomFill(void *buffer, size_t size)
Fill the given memory buffer with random bytes.
C++ Common project definitions.