FixedSizeAllocatorWithCleanup< T, S, A, false > Class Template Reference

Static secure memory block with cleanup. More...

`#include <secblock.h>`

Inheritance diagram for FixedSizeAllocatorWithCleanup< T, S, A, false >:

## 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 Types inherited from AllocatorBase< T >
typedef T | value_type
typedef size_t | size_type
typedef std::ptrdiff_t | difference_type
typedef T * | pointer
typedef const T * | const_pointer
typedef T & | reference
typedef const T & | const_reference

## Public Member Functions

| FixedSizeAllocatorWithCleanup ()
| Constructs a FixedSizeAllocatorWithCleanup.
pointer | allocate (size_type size)
| Allocates a block of memory.
pointer | allocate (size_type size, const void *hint)
| Allocates a block of memory.
void | deallocate (void *ptr, size_type size)
| Deallocates a block of memory.
pointer | reallocate (pointer oldPtr, size_type oldSize, size_type newSize, bool preserve)
| Reallocates a block of memory.
size_type | max_size () const
Public Member Functions inherited from AllocatorBase< T >
pointer | address (reference r) const
const_pointer | address (const_reference r) const
void | construct (pointer p, const T &val)
void | destroy (pointer p)
size_type | max_size () const
| Returns the maximum number of elements the allocator can provide.
template<typename V, typename... Args>
void | construct (V *ptr, Args &&... args)
| Constructs a new V using variadic arguments.
template<typename V>
void | destroy (V *ptr)
| Destroys an V constructed with variadic arguments.

## Additional Inherited Members

Static Public Attributes inherited from AllocatorBase< T >
static const size_type | ELEMS_MAX = ...
| Returns the maximum number of elements the allocator can provide.

## Detailed Description

template<class T, size_t S, class A>
class FixedSizeAllocatorWithCleanup< T, S, A, false >

Static secure memory block with cleanup.

Template Parameters

  T | class or type
  S | fixed-size of the stack-based memory block, in elements

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 578 of file secblock.h.

## Member Typedef Documentation

## value_type

template<class T, size_t S, class A>

typedef AllocatorBase<T>::value_type FixedSizeAllocatorWithCleanup< T, S, A, false >::value_type

Definition at line 581 of file secblock.h.

## size_type

template<class T, size_t S, class A>

typedef AllocatorBase<T>::size_type FixedSizeAllocatorWithCleanup< T, S, A, false >::size_type

Definition at line 581 of file secblock.h.

## difference_type

template<class T, size_t S, class A>

typedef AllocatorBase<T>::difference_type FixedSizeAllocatorWithCleanup< T, S, A, false >::difference_type

Definition at line 581 of file secblock.h.

## pointer

template<class T, size_t S, class A>

typedef AllocatorBase<T>::pointer FixedSizeAllocatorWithCleanup< T, S, A, false >::pointer

Definition at line 581 of file secblock.h.

## const_pointer

template<class T, size_t S, class A>

typedef AllocatorBase<T>::const_pointer FixedSizeAllocatorWithCleanup< T, S, A, false >::const_pointer

Definition at line 581 of file secblock.h.

## reference

template<class T, size_t S, class A>

typedef AllocatorBase<T>::reference FixedSizeAllocatorWithCleanup< T, S, A, false >::reference

Definition at line 581 of file secblock.h.

## const_reference

template<class T, size_t S, class A>

typedef AllocatorBase<T>::const_reference FixedSizeAllocatorWithCleanup< T, S, A, false >::const_reference

Definition at line 581 of file secblock.h.

## Constructor & Destructor Documentation

## FixedSizeAllocatorWithCleanup()

template<class T, size_t S, class A>

FixedSizeAllocatorWithCleanup< T, S, A, false >::FixedSizeAllocatorWithCleanup | ( |  | ) |

inline

Constructs a FixedSizeAllocatorWithCleanup.

Definition at line 584 of file secblock.h.

## Member Function Documentation

## allocate() [1/2]

template<class T, size_t S, class A>

pointer FixedSizeAllocatorWithCleanup< T, S, A, false >::allocate | ( | size_type | size | ) |

inline

Allocates a block of memory.

Parameters

  size | the count elements in 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.

See also
  reallocate(), SecBlockWithHint

Definition at line 598 of file secblock.h.

## allocate() [2/2]

template<class T, size_t S, class A>

pointer FixedSizeAllocatorWithCleanup< T, S, A, false >::allocate | ( | size_type | size,
|  | const void * | hint )

inline

Allocates a block of memory.

Parameters

  size | the count elements in the memory block
  hint | an 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.

See also
  reallocate(), SecBlockWithHint

Definition at line 624 of file secblock.h.

## deallocate()

template<class T, size_t S, class A>

void FixedSizeAllocatorWithCleanup< T, S, A, false >::deallocate | ( | void * | ptr,
|  | size_type | size )

inline

Deallocates a block of memory.

Parameters

  ptr | a pointer to the memory block to deallocate
  size | the count elements in 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 643 of file secblock.h.

## reallocate()

template<class T, size_t S, class A>

pointer FixedSizeAllocatorWithCleanup< T, S, A, false >::reallocate | ( | pointer | oldPtr,
|  | size_type | oldSize,
|  | size_type | newSize,
|  | bool | preserve )

inline

Reallocates a block of memory.

Parameters

  oldPtr | the previous allocation
  oldSize | the size of the previous allocation
  newSize | the new, requested size
  preserve | flag 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 682 of file secblock.h.

## max_size()

template<class T, size_t S, class A>

size_type FixedSizeAllocatorWithCleanup< T, S, A, false >::max_size | ( |  | ) | const

inline

Definition at line 703 of file secblock.h.

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

- secblock.h