Fabcoin Core
0.16.2
P2P Digital Currency
|
Allocates a block of memory with cleanup. More...
#include <secblock.h>
Classes | |
struct | rebind |
Template class memeber Rebind. More... | |
Public Member Functions | |
CRYPTOPP_INHERIT_ALLOCATOR_TYPES pointer | allocate (size_type size, const void *ptr=NULL) |
Allocates a block of memory. More... | |
void | deallocate (void *ptr, size_type size) |
Deallocates a block of memory. More... | |
pointer | reallocate (T *oldPtr, size_type oldSize, size_type newSize, bool preserve) |
Reallocates a block of memory. More... | |
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) |
CRYPTOPP_CONSTEXPR size_type | max_size () const |
Returns the maximum number of elements the allocator can provide. More... | |
Additional Inherited Members | |
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 |
Static Protected Member Functions inherited from AllocatorBase< T > | |
static void | CheckSize (size_t size) |
Verifies the allocator can satisfy a request based on size. More... | |
Allocates a block of memory with cleanup.
T | class or type |
T_Align16 | boolean that determines whether allocations should be aligned on 16-byte boundaries |
If T_Align16 is true, then AllocatorWithCleanup calls AlignedAllocate() for memory allocations. If T_Align16 is false, then AllocatorWithCleanup() calls UnalignedAllocate() for memory allocations.
Template parameter T_Align16 is effectively controlled by cryptlib.h and mirrors CRYPTOPP_BOOL_ALIGN16. CRYPTOPP_BOOL_ALIGN16 is often used as the template parameter.
Definition at line 151 of file secblock.h.
|
inline |
Allocates a block of memory.
ptr | the size of the allocation |
size | the size of the allocation, in elements |
InvalidArgument |
allocate() first checks the size of the request. If it is non-0 and less than max_size(), then an attempt is made to fulfill the request using either AlignedAllocate() or UnalignedAllocate().
AlignedAllocate() is used if T_Align16 is true. UnalignedAllocate() used if T_Align16 is false.
This is the C++ Placement New operator. ptr is not used, and the function CRYPTOPP_ASSERTs in Debug builds if ptr is non-NULL.
Definition at line 171 of file secblock.h.
|
inline |
Deallocates a block of memory.
ptr | the pointer for the allocation |
size | the size of the allocation, in elements |
Internally, SecureWipeArray() is called before deallocating the memory. Once the memory block is wiped or zeroized, AlignedDeallocate() or UnalignedDeallocate() is called.
AlignedDeallocate() is used if T_Align16 is true. UnalignedDeallocate() used if T_Align16 is false.
Definition at line 195 of file secblock.h.
|
inline |
Reallocates a block of memory.
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 |
Internally, reallocate() calls StandardReallocate().
If preserve is true, then index 0 is used to begin copying the old memory block to the new one. If the block grows, then the old array is copied in its entirety. If the block shrinks, then only newSize elements are copied from the old block to the new one.
Definition at line 221 of file secblock.h.