diff options
author | lloyd <[email protected]> | 2006-05-18 18:33:19 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-05-18 18:33:19 +0000 |
commit | a2c99d3270eb73ef2db5704fc54356c6b75096f8 (patch) | |
tree | ad3d6c4fcc8dd0f403f8105598943616246fe172 /include/mem_ops.h |
Initial checkin1.5.6
Diffstat (limited to 'include/mem_ops.h')
-rw-r--r-- | include/mem_ops.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/mem_ops.h b/include/mem_ops.h new file mode 100644 index 000000000..712284cd9 --- /dev/null +++ b/include/mem_ops.h @@ -0,0 +1,31 @@ +/************************************************* +* Memory Operations Header File * +* (C) 1999-2006 The Botan Project * +*************************************************/ + +#ifndef BOTAN_MEMORY_OPS_H__ +#define BOTAN_MEMORY_OPS_H__ + +#include <botan/types.h> +#include <cstring> + +namespace Botan { + +/************************************************* +* Memory Manipulation Functions * +*************************************************/ +template<typename T> inline void copy_mem(T* out, const T* in, u32bit n) + { std::memmove(out, in, sizeof(T)*n); } + +template<typename T> inline void clear_mem(T* ptr, u32bit n) + { std::memset(ptr, 0, sizeof(T)*n); } + +template<typename T> inline void set_mem(T* ptr, u32bit n, byte val) + { std::memset(ptr, val, sizeof(T)*n); } + +template<typename T> inline bool same_mem(const T* p1, const T* p2, u32bit n) + { return (std::memcmp(p1, p2, sizeof(T)*n) == 0); } + +} + +#endif |