From 579a5c8a706cdb381bf99289f0885b53a9af773c Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 29 Dec 2020 13:24:34 -0500 Subject: Update comments --- secblock.h | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'secblock.h') 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 { // 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 -- cgit v1.2.1