monotone

monotone Mtn Source Tree

Root/botan/mem_ops.h

1/*************************************************
2* Memory Operations Header File *
3* (C) 1999-2006 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_MEMORY_OPS_H__
7#define BOTAN_MEMORY_OPS_H__
8
9#include <botan/types.h>
10#include <cstring>
11
12namespace Botan {
13
14/*************************************************
15* Memory Manipulation Functions *
16*************************************************/
17template<typename T> inline void copy_mem(T* out, const T* in, u32bit n)
18 { std::memmove(out, in, sizeof(T)*n); }
19
20template<typename T> inline void clear_mem(T* ptr, u32bit n)
21 { std::memset(ptr, 0, sizeof(T)*n); }
22
23template<typename T> inline void set_mem(T* ptr, u32bit n, byte val)
24 { std::memset(ptr, val, sizeof(T)*n); }
25
26template<typename T> inline bool same_mem(const T* p1, const T* p2, u32bit n)
27 { return (std::memcmp(p1, p2, sizeof(T)*n) == 0); }
28
29}
30
31#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status