Fabcoin Core
0.16.2
P2P Digital Currency
|
Secure memory block with allocator and cleanup. More...
#include <secblock.h>
Public Types | |
typedef A::value_type | value_type |
typedef A::pointer | iterator |
typedef A::const_pointer | const_iterator |
typedef A::size_type | size_type |
Public Member Functions | |
SecBlock (size_type size=0) | |
Construct a SecBlock with space for size elements. More... | |
SecBlock (const SecBlock< T, A > &t) | |
Copy construct a SecBlock from another SecBlock. More... | |
SecBlock (const T *ptr, size_type len) | |
Construct a SecBlock from an array of elements. More... | |
~SecBlock () | |
operator const void * () const | |
operator void * () | |
operator const T * () const | |
operator T * () | |
iterator | begin () |
Provides an iterator pointing to the first element in the memory block. More... | |
const_iterator | begin () const |
Provides a constant iterator pointing to the first element in the memory block. More... | |
iterator | end () |
Provides an iterator pointing beyond the last element in the memory block. More... | |
const_iterator | end () const |
Provides a constant iterator pointing beyond the last element in the memory block. More... | |
A::pointer | data () |
Provides a pointer to the first element in the memory block. More... | |
A::const_pointer | data () const |
Provides a pointer to the first element in the memory block. More... | |
size_type | size () const |
Provides the count of elements in the SecBlock. More... | |
bool | empty () const |
Determines if the SecBlock is empty. More... | |
byte * | BytePtr () |
Provides a byte pointer to the first element in the memory block. More... | |
const byte * | BytePtr () const |
Return a byte pointer to the first element in the memory block. More... | |
size_type | SizeInBytes () const |
Provides the number of bytes in the SecBlock. More... | |
void | Assign (const T *ptr, size_type len) |
Set contents and size from an array. More... | |
void | Assign (const SecBlock< T, A > &t) |
Copy contents from another SecBlock. More... | |
SecBlock< T, A > & | operator= (const SecBlock< T, A > &t) |
Assign contents from another SecBlock. More... | |
SecBlock< T, A > & | operator+= (const SecBlock< T, A > &t) |
Append contents from another SecBlock. More... | |
SecBlock< T, A > | operator+ (const SecBlock< T, A > &t) |
Construct a SecBlock from this and another SecBlock. More... | |
bool | operator== (const SecBlock< T, A > &t) const |
Bitwise compare two SecBlocks. More... | |
bool | operator!= (const SecBlock< T, A > &t) const |
Bitwise compare two SecBlocks. More... | |
void | New (size_type newSize) |
Change size without preserving contents. More... | |
void | CleanNew (size_type newSize) |
Change size without preserving contents. More... | |
void | Grow (size_type newSize) |
Change size and preserve contents. More... | |
void | CleanGrow (size_type newSize) |
Change size and preserve contents. More... | |
void | resize (size_type newSize) |
Change size and preserve contents. More... | |
void | swap (SecBlock< T, A > &b) |
Swap contents with another SecBlock. More... | |
Public Attributes | |
A | m_alloc |
size_type | m_size |
T * | m_ptr |
Secure memory block with allocator and cleanup.
T | a class or type |
A | AllocatorWithCleanup derived class for allocation and cleanup |
Definition at line 437 of file secblock.h.
typedef A::const_pointer SecBlock< T, A >::const_iterator |
Definition at line 442 of file secblock.h.
Definition at line 441 of file secblock.h.
typedef A::size_type SecBlock< T, A >::size_type |
Definition at line 443 of file secblock.h.
typedef A::value_type SecBlock< T, A >::value_type |
Definition at line 440 of file secblock.h.
|
inlineexplicit |
Construct a SecBlock with space for size elements.
size | the size of the allocation, in elements |
std::bad_alloc |
The elements are not initialized.
Definition at line 450 of file secblock.h.
|
inline |
Copy construct a SecBlock from another SecBlock.
t | the other SecBlock |
std::bad_alloc |
Definition at line 456 of file secblock.h.
|
inline |
Construct a SecBlock from an array of elements.
ptr | a pointer to an array of T |
len | the number of elements in the memory block |
std::bad_alloc |
If ptr!=NULL
and len!=0
, then the block is initialized from the pointer ptr. If ptr==NULL
and len!=0
, then the block is initialized to 0. Otherwise, the block is empty and not initialized.
Definition at line 470 of file secblock.h.
Definition at line 479 of file secblock.h.
|
inline |
Set contents and size from an array.
ptr | a pointer to an array of T |
len | the number of elements in the memory block |
If the memory block is reduced in size, then the reclaimed memory is set to 0.
Definition at line 544 of file secblock.h.
|
inline |
Copy contents from another SecBlock.
t | the other SecBlock |
Assign checks for self assignment.
If the memory block is reduced in size, then the reclaimed memory is set to 0.
Definition at line 555 of file secblock.h.
Provides an iterator pointing to the first element in the memory block.
Definition at line 499 of file secblock.h.
|
inline |
Provides a constant iterator pointing to the first element in the memory block.
Definition at line 503 of file secblock.h.
Provides a byte pointer to the first element in the memory block.
Definition at line 531 of file secblock.h.
|
inline |
Return a byte pointer to the first element in the memory block.
Definition at line 534 of file secblock.h.
|
inline |
Change size and preserve contents.
newSize | the new size of the memory block |
Old content is preserved. New content is initialized to 0.
Internally, this SecBlock calls reallocate() when size must increase. If the size does not increase, then CleanGrow() does not take action. If the size must change, then use resize().
Definition at line 689 of file secblock.h.
|
inline |
Change size without preserving contents.
newSize | the new size of the memory block |
Old content is not preserved. If the memory block is reduced in size, then the reclaimed content is set to 0. If the memory block grows in size, then the new memory is initialized to 0.
Internally, this SecBlock calls New().
Definition at line 660 of file secblock.h.
Provides a pointer to the first element in the memory block.
Definition at line 516 of file secblock.h.
|
inline |
Provides a pointer to the first element in the memory block.
Definition at line 519 of file secblock.h.
Determines if the SecBlock is empty.
Definition at line 527 of file secblock.h.
Provides an iterator pointing beyond the last element in the memory block.
Definition at line 507 of file secblock.h.
|
inline |
Provides a constant iterator pointing beyond the last element in the memory block.
Definition at line 511 of file secblock.h.
|
inline |
Change size and preserve contents.
newSize | the new size of the memory block |
Old content is preserved. New content is not initialized.
Internally, this SecBlock calls reallocate() when size must increase. If the size does not increase, then Grow() does not take action. If the size must change, then use resize().
Definition at line 673 of file secblock.h.
|
inline |
Change size without preserving contents.
newSize | the new size of the memory block |
Old content is not preserved. If the memory block is reduced in size, then the reclaimed memory is set to 0. If the memory block grows in size, then the new memory is not initialized.
Internally, this SecBlock calls reallocate().
Definition at line 647 of file secblock.h.
|
inline |
Definition at line 491 of file secblock.h.
|
inline |
Definition at line 486 of file secblock.h.
Definition at line 493 of file secblock.h.
Definition at line 488 of file secblock.h.
|
inline |
Bitwise compare two SecBlocks.
t | the other SecBlock |
Uses a constant time compare if the arrays are equal size. The constant time compare is VerifyBufsEqual() found in misc.h.
Internally, operator!=() returns the inverse of operator==().
Definition at line 635 of file secblock.h.
|
inline |
Append contents from another SecBlock.
t | the other SecBlock |
Internally, this SecBlock calls Grow and then appends t.
Definition at line 579 of file secblock.h.
|
inline |
Assign contents from another SecBlock.
t | the other SecBlock |
Internally, operator=() calls Assign().
If the memory block is reduced in size, then the reclaimed memory is set to 0.
Definition at line 569 of file secblock.h.
|
inline |
Bitwise compare two SecBlocks.
t | the other SecBlock |
Uses a constant time compare if the arrays are equal size. The constant time compare is VerifyBufsEqual() found in misc.h.
Definition at line 622 of file secblock.h.
|
inline |
Change size and preserve contents.
newSize | the new size of the memory block |
Old content is preserved. If the memory block grows in size, then new memory is not initialized.
Internally, this SecBlock calls reallocate().
Definition at line 705 of file secblock.h.
|
inline |
Provides the count of elements in the SecBlock.
Definition at line 524 of file secblock.h.
|
inline |
Provides the number of bytes in the SecBlock.
Definition at line 538 of file secblock.h.
|
inline |
Swap contents with another SecBlock.
b | the other SecBlock |
Internally, std::swap() is called on m_alloc, m_size and m_ptr.
Definition at line 714 of file secblock.h.
Definition at line 723 of file secblock.h.
Definition at line 725 of file secblock.h.
Definition at line 724 of file secblock.h.