summaryrefslogtreecommitdiff
path: root/secblock.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2020-12-29 13:24:34 -0500
committerJeffrey Walton <noloader@gmail.com>2020-12-29 13:24:34 -0500
commit579a5c8a706cdb381bf99289f0885b53a9af773c (patch)
tree20454d7abeae65ffe662cde49c701e7db0b20b3b /secblock.h
parent4bc7408ae2aefac9357c16809541ecbe225b7f3a (diff)
downloadcryptopp-git-579a5c8a706cdb381bf99289f0885b53a9af773c.tar.gz
Update comments
Diffstat (limited to 'secblock.h')
-rw-r--r--secblock.h33
1 files changed, 17 insertions, 16 deletions
diff --git a/secblock.h b/secblock.h
index 39beb677..9fa7fd86 100644
--- a/secblock.h
+++ b/secblock.h
@@ -155,16 +155,16 @@ typename A::pointer StandardReallocate(A& alloc, T *oldPtr, typename A::size_typ
if (preserve)
{
- typename A::pointer newPointer = alloc.allocate(newSize, NULLPTR);
+ typename A::pointer newPtr = alloc.allocate(newSize, NULLPTR);
const typename A::size_type copySize = STDMIN(oldSize, newSize) * sizeof(T);
- if (oldPtr && newPointer)
- memcpy_s(newPointer, copySize, oldPtr, copySize);
+ if (oldPtr && newPtr)
+ memcpy_s(newPtr, copySize, oldPtr, copySize);
if (oldPtr)
alloc.deallocate(oldPtr, oldSize);
- return newPointer;
+ return newPtr;
}
else
{
@@ -337,9 +337,7 @@ class FixedSizeAllocatorWithCleanup : public AllocatorBase<T>
{
// The body of FixedSizeAllocatorWithCleanup is provided in the two
// partial specializations that follow. The two specializations
- // pivot on the boolean template parameter T_Align16. AIX, Solaris,
- // IBM XLC and SunCC receive a little extra help. We managed to
- // clear most of the warnings.
+ // pivot on the boolean template parameter T_Align16.
};
/// \brief Static secure memory block with cleanup
@@ -401,6 +399,8 @@ public:
/// \sa reallocate(), SecBlockWithHint
pointer allocate(size_type size, const void *hint)
{
+ CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8));
+
if (size <= S && !m_allocated)
{
m_allocated = true;
@@ -468,15 +468,15 @@ public:
return oldPtr;
}
- pointer newPointer = allocate(newSize, NULLPTR);
+ pointer newPtr = allocate(newSize, NULLPTR);
if (preserve && newSize)
{
const size_type copySize = STDMIN(oldSize, newSize);
- if (newPointer && oldPtr) // GCC analyzer warning
- memcpy_s(newPointer, sizeof(T)*newSize, oldPtr, sizeof(T)*copySize);
+ if (newPtr && oldPtr) // GCC analyzer warning
+ memcpy_s(newPtr, sizeof(T)*newSize, oldPtr, sizeof(T)*copySize);
}
deallocate(oldPtr, oldSize);
- return newPointer;
+ return newPtr;
}
CRYPTOPP_CONSTEXPR size_type max_size() const
@@ -547,7 +547,8 @@ private:
#else
- // CRYPTOPP_BOOL_ALIGN16 is 0. Normally we would use the natural
+ // CRYPTOPP_BOOL_ALIGN16 is 0. The user likely compiled with
+ // CRYPTOPP_DISABLE_ASM. Normally we would use the natural
// alignment of T. The problem we are having is, some toolchains
// are changing the boundary for 64-bit arrays. 64-bit elements
// require 8-byte alignment, but the toolchain is laying the array
@@ -687,15 +688,15 @@ public:
return oldPtr;
}
- pointer newPointer = allocate(newSize, NULLPTR);
+ pointer newPtr = allocate(newSize, NULLPTR);
if (preserve && newSize)
{
const size_type copySize = STDMIN(oldSize, newSize);
- if (newPointer && oldPtr) // GCC analyzer warning
- memcpy_s(newPointer, sizeof(T)*newSize, oldPtr, sizeof(T)*copySize);
+ if (newPtr && oldPtr) // GCC analyzer warning
+ memcpy_s(newPtr, sizeof(T)*newSize, oldPtr, sizeof(T)*copySize);
}
deallocate(oldPtr, oldSize);
- return newPointer;
+ return newPtr;
}
CRYPTOPP_CONSTEXPR size_type max_size() const