Botan  1.11.15
Public Types | Public Member Functions
Botan::secure_allocator< T > Class Template Reference

#include <secmem.h>

List of all members.

Public Types

typedef const T * const_pointer
typedef const T & const_reference
typedef std::ptrdiff_t difference_type
typedef T * pointer
typedef T & reference
typedef std::size_t size_type
typedef T value_type

Public Member Functions

pointer address (reference x) const noexcept
const_pointer address (const_reference x) const noexcept
pointer allocate (size_type n, const void *=0)
template<typename U , typename... Args>
void construct (U *p, Args &&...args)
void deallocate (pointer p, size_type n)
template<typename U >
void destroy (U *p)
size_type max_size () const noexcept
 secure_allocator () noexcept
 ~secure_allocator () noexcept

Detailed Description

template<typename T>
class Botan::secure_allocator< T >

Definition at line 23 of file secmem.h.


Member Typedef Documentation

template<typename T >
typedef const T* Botan::secure_allocator< T >::const_pointer

Definition at line 29 of file secmem.h.

template<typename T >
typedef const T& Botan::secure_allocator< T >::const_reference

Definition at line 32 of file secmem.h.

template<typename T >
typedef std::ptrdiff_t Botan::secure_allocator< T >::difference_type

Definition at line 35 of file secmem.h.

template<typename T >
typedef T* Botan::secure_allocator< T >::pointer

Definition at line 28 of file secmem.h.

template<typename T >
typedef T& Botan::secure_allocator< T >::reference

Definition at line 31 of file secmem.h.

template<typename T >
typedef std::size_t Botan::secure_allocator< T >::size_type

Definition at line 34 of file secmem.h.

template<typename T >
typedef T Botan::secure_allocator< T >::value_type

Definition at line 26 of file secmem.h.


Constructor & Destructor Documentation

template<typename T >
Botan::secure_allocator< T >::secure_allocator ( ) [inline]

Definition at line 37 of file secmem.h.

{}
template<typename T >
Botan::secure_allocator< T >::~secure_allocator ( ) [inline]

Definition at line 39 of file secmem.h.

{}

Member Function Documentation

template<typename T >
pointer Botan::secure_allocator< T >::address ( reference  x) const [inline]

Definition at line 41 of file secmem.h.

References x.

         { return std::addressof(x); }
template<typename T >
const_pointer Botan::secure_allocator< T >::address ( const_reference  x) const [inline]

Definition at line 44 of file secmem.h.

References x.

         { return std::addressof(x); }
template<typename T >
pointer Botan::secure_allocator< T >::allocate ( size_type  n,
const void *  = 0 
) [inline]

Definition at line 47 of file secmem.h.

References Botan::clear_mem(), Botan::mlock_allocator::instance(), and n.

         {
#if defined(BOTAN_HAS_LOCKING_ALLOCATOR)
         if(pointer p = static_cast<pointer>(mlock_allocator::instance().allocate(n, sizeof(T))))
            return p;
#endif

         pointer p = new T[n];
         clear_mem(p, n);
         return p;
         }
template<typename T >
template<typename U , typename... Args>
void Botan::secure_allocator< T >::construct ( U *  p,
Args &&...  args 
) [inline]

Definition at line 77 of file secmem.h.

         {
         ::new(static_cast<void*>(p)) U(std::forward<Args>(args)...);
         }
template<typename T >
void Botan::secure_allocator< T >::deallocate ( pointer  p,
size_type  n 
) [inline]

Definition at line 59 of file secmem.h.

References Botan::mlock_allocator::instance(), and Botan::zero_mem().

         {
         zero_mem(p, n);

#if defined(BOTAN_HAS_LOCKING_ALLOCATOR)
         if(mlock_allocator::instance().deallocate(p, n, sizeof(T)))
            return;
#endif

         delete [] p;
         }
template<typename T >
template<typename U >
void Botan::secure_allocator< T >::destroy ( U *  p) [inline]

Definition at line 82 of file secmem.h.

{ p->~U(); }
template<typename T >
size_type Botan::secure_allocator< T >::max_size ( ) const [inline]

Definition at line 71 of file secmem.h.

         {
         return static_cast<size_type>(-1) / sizeof(T);
         }

The documentation for this class was generated from the following file: