TEST(AlignedAllocatorTest, AllocatorAlign) { AlignedAllocator<real> a; real * p = a.allocate(1000); // Mask for 128-byte alignment is 128-1 - these bits should be zero in p std::size_t mask = static_cast<std::size_t>(128-1); EXPECT_EQ(0, reinterpret_cast<std::size_t>(p) & mask); a.deallocate(p, 1000); }
void KeyAgreementResponder::FreeMemory() { AlignedAllocator *allocator = AlignedAllocator::ref(); if (b) { CAT_SECURE_CLR(b, KeyBytes); CAT_SECURE_CLR(y[0], KeyBytes); CAT_SECURE_CLR(y[1], KeyBytes); allocator->Delete(b); b = 0; } if (G_MultPrecomp) { allocator->Delete(G_MultPrecomp); G_MultPrecomp = 0; } }
// msvc 14.10.25017 (VC++ 2017 March release) fails with an internal error with conditional noexcept // ~aligned_ptr() noexcept(std::is_nothrow_destructible_v<value_type>) {} ~aligned_padded_ptr() noexcept { if (ptr) { deleter(ptr); allocator.deallocate(reinterpret_cast<std::uint8_t*>(ptr), block_size); } }
aligned_padded_ptr(Ts&&... ts) : ptr(reinterpret_cast<T*>(allocator.allocate(block_size))) { make(ptr, std::forward<Ts>(ts)...); }