aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/mem_ops.h
diff options
context:
space:
mode:
authorlloyd <lloyd@randombit.net>2008-09-28 23:59:53 +0000
committerlloyd <lloyd@randombit.net>2008-09-28 23:59:53 +0000
commit45c4fcfce66d894dda6b1d29a92fa47515b944af (patch)
tree75b96e2003588308e098d8b4a8dfcc4f89df9780 /src/utils/mem_ops.h
parentc14cca7ef7338de3a8da784dd0865634b4110539 (diff)
More headers (loadstore, mem_ops, rotate, types) for util module
Diffstat (limited to 'src/utils/mem_ops.h')
-rw-r--r--src/utils/mem_ops.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/utils/mem_ops.h b/src/utils/mem_ops.h
new file mode 100644
index 000000000..810356bce
--- /dev/null
+++ b/src/utils/mem_ops.h
@@ -0,0 +1,31 @@
+/*************************************************
+* Memory Operations Header File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#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