Crypto++  5.6.3
Free C++ class library of cryptographic schemes
Public Types | Public Member Functions | List of all members
FixedSizeAllocatorWithCleanup< T, S, A, T_Align16 > Class Template Reference

Static secure memory block with cleanup. More...

+ Inheritance diagram for FixedSizeAllocatorWithCleanup< T, S, A, T_Align16 >:

Public Types

typedef AllocatorBase< T >::value_type value_type
 
typedef AllocatorBase< T >::size_type size_type
 
typedef AllocatorBase< T >::difference_type difference_type
 
typedef AllocatorBase< T >::pointer pointer
 
typedef AllocatorBase< T >::const_pointer const_pointer
 
typedef AllocatorBase< T >::reference reference
 
typedef AllocatorBase< T >::const_reference const_reference
 

Public Member Functions

 FixedSizeAllocatorWithCleanup ()
 Constructs a FixedSizeAllocatorWithCleanup.
 
pointer allocate (size_type size)
 Allocates a block of memory. More...
 
pointer allocate (size_type size, const void *hint)
 Allocates a block of memory. More...
 
void deallocate (void *ptr, size_type size)
 Deallocates a block of memory. More...
 
pointer reallocate (pointer oldPtr, size_type oldSize, size_type newSize, bool preserve)
 Reallocates a block of memory. More...
 
size_type max_size () const
 
pointer address (reference r) const
 
const_pointer address (const_reference r) const
 
void construct (pointer p, const T &val)
 
template<typename U , typename... Args>
void construct (U *ptr, Args &&...args)
 Constructs a new U using variadic arguments. More...
 
void destroy (pointer p)
 
template<typename U >
void destroy (U *ptr)
 Destroys an U constructed with variadic arguments. More...
 

Detailed Description

template<class T, size_t S, class A = NullAllocator<T>, bool T_Align16 = false>
class FixedSizeAllocatorWithCleanup< T, S, A, T_Align16 >

Static secure memory block with cleanup.

Template Parameters
Tclass or type
Sfixed-size of the stack-based memory block
AAllocatorBase derived class for allocation and cleanup

FixedSizeAllocatorWithCleanup provides a fixed-size, stack- based allocation at compile time. The class can grow its memory block at runtime if a suitable allocator is available. If size grows beyond S and a suitable allocator is available, then the statically allocated array is obsoleted.

Note
This allocator can't be used with standard collections because they require that all objects of the same allocator type are equivalent.

Definition at line 286 of file secblock.h.

Member Function Documentation

template<class T, size_t S, class A = NullAllocator<T>, bool T_Align16 = false>
pointer FixedSizeAllocatorWithCleanup< T, S, A, T_Align16 >::allocate ( size_type  size)
inline

Allocates a block of memory.

Parameters
sizesize of the memory block

FixedSizeAllocatorWithCleanup provides a fixed-size, stack- based allocation at compile time. If size is less than or equal to S, then a pointer to the static array is returned.

The class can grow its memory block at runtime if a suitable allocator is available. If size grows beyond S and a suitable allocator is available, then the statically allocated array is obsoleted. If a suitable allocator is not available, as with a NullAllocator, then the function returns NULL and a runtime error eventually occurs.

Note
size is the count of elements, and not the number of bytes.
See also
reallocate(), SecBlockWithHint

Definition at line 307 of file secblock.h.

template<class T, size_t S, class A = NullAllocator<T>, bool T_Align16 = false>
pointer FixedSizeAllocatorWithCleanup< T, S, A, T_Align16 >::allocate ( size_type  size,
const void *  hint 
)
inline

Allocates a block of memory.

Parameters
sizesize of the memory block
hintan unused hint

FixedSizeAllocatorWithCleanup provides a fixed-size, stack- based allocation at compile time. If size is less than or equal to S, then a pointer to the static array is returned.

The class can grow its memory block at runtime if a suitable allocator is available. If size grows beyond S and a suitable allocator is available, then the statically allocated array is obsoleted. If a suitable allocator is not available, as with a NullAllocator, then the function returns NULL and a runtime error eventually occurs.

Note
size is the count of elements, and not the number of bytes.
See also
reallocate(), SecBlockWithHint

Definition at line 334 of file secblock.h.

template<class T, size_t S, class A = NullAllocator<T>, bool T_Align16 = false>
void FixedSizeAllocatorWithCleanup< T, S, A, T_Align16 >::deallocate ( void *  ptr,
size_type  size 
)
inline

Deallocates a block of memory.

Parameters
ptra pointer to the memory block to deallocate
sizesize of the memory block

The memory block is wiped or zeroized before deallocation. If the statically allocated memory block is active, then no additional actions are taken after the wipe.

If a dynamic memory block is active, then the pointer and size are passed to the allocator for deallocation.

Definition at line 353 of file secblock.h.

template<class T, size_t S, class A = NullAllocator<T>, bool T_Align16 = false>
pointer FixedSizeAllocatorWithCleanup< T, S, A, T_Align16 >::reallocate ( pointer  oldPtr,
size_type  oldSize,
size_type  newSize,
bool  preserve 
)
inline

Reallocates a block of memory.

Parameters
oldPtrthe previous allocation
oldSizethe size of the previous allocation
newSizethe new, requested size
preserveflag that indicates if the old allocation should be preserved
Returns
pointer to the new memory block

FixedSizeAllocatorWithCleanup provides a fixed-size, stack- based allocation at compile time. If size is less than or equal to S, then a pointer to the static array is returned.

The class can grow its memory block at runtime if a suitable allocator is available. If size grows beyond S and a suitable allocator is available, then the statically allocated array is obsoleted. If a suitable allocator is not available, as with a NullAllocator, then the function returns NULL and a runtime error eventually occurs.

Note
size is the count of elements, and not the number of bytes.
See also
reallocate(), SecBlockWithHint

Definition at line 383 of file secblock.h.

template<class T>
template<typename U , typename... Args>
void AllocatorBase< T >::construct ( U *  ptr,
Args &&...  args 
)
inlineinherited

Constructs a new U using variadic arguments.

Template Parameters
Uthe type to be forwarded
Argsthe arguments to be forwarded
Parameters
ptrpointer to type U
argsvariadic arguments

This is a C++11 feature. It is available when CRYPTOPP_CXX11_VARIADIC_TEMPLATES is defined. The define is controlled by compiler versions detected in config.h.

Definition at line 64 of file secblock.h.

template<class T>
template<typename U >
void AllocatorBase< T >::destroy ( U *  ptr)
inlineinherited

Destroys an U constructed with variadic arguments.

Template Parameters
Uthe type to be forwarded

This is a C++11 feature. It is available when CRYPTOPP_CXX11_VARIADIC_TEMPLATES is defined. The define is controlled by compiler versions detected in config.h.

Definition at line 71 of file secblock.h.


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