10 #ifndef CRYPTOPP_IMPORTS 18 #if defined(CRYPTOPP_MEMALIGN_AVAILABLE) || defined(CRYPTOPP_MM_MALLOC_AVAILABLE) || defined(QNX) 22 #if defined(CRYPTOPP_POSIX_MEMALIGN_AVAILABLE) 30 using std::new_handler;
31 using std::set_new_handler;
33 new_handler newHandler = set_new_handler(NULLPTR);
35 set_new_handler(newHandler);
40 throw std::bad_alloc();
46 #if defined(CRYPTOPP_MM_MALLOC_AVAILABLE) 47 while ((p = (byte *)_mm_malloc(size, 16)) == NULLPTR)
48 #elif defined(CRYPTOPP_MEMALIGN_AVAILABLE) 49 while ((p = (byte *)memalign(16, size)) == NULLPTR)
50 #elif defined(CRYPTOPP_MALLOC_ALIGNMENT_IS_16) 51 while ((p = (byte *)malloc(size)) == NULLPTR)
52 #elif defined(CRYPTOPP_POSIX_MEMALIGN_AVAILABLE) 53 while (posix_memalign(reinterpret_cast<void**>(&p), 16, size) != 0)
55 while ((p = (byte *)malloc(size + 16)) == NULLPTR)
59 #ifdef CRYPTOPP_NO_ALIGNED_ALLOC 60 size_t adjustment = 16-((size_t)p%16);
63 p[-1] = (byte)adjustment;
81 #ifdef CRYPTOPP_MM_MALLOC_AVAILABLE 83 #elif defined(CRYPTOPP_NO_ALIGNED_ALLOC) 84 p = (byte *)p - ((byte *)p)[-1];
95 while ((p = malloc(size)) == NULLPTR)
107 #endif // CRYPTOPP_IMPORTS CRYPTOPP_DLL void CRYPTOPP_API UnalignedDeallocate(void *ptr)
Frees a buffer allocated with UnalignedAllocate.
Utility functions for the Crypto++ library.
CRYPTOPP_DLL void CRYPTOPP_API CallNewHandler()
Attempts to reclaim unused memory.
CRYPTOPP_DLL void *CRYPTOPP_API AlignedAllocate(size_t size)
Allocates a buffer on 16-byte boundary.
Library configuration file.
Functions for allocating aligned buffers.
bool IsAlignedOn(const void *ptr, unsigned int alignment)
Determines whether ptr is aligned to a minimum value.
CRYPTOPP_DLL void *CRYPTOPP_API UnalignedAllocate(size_t size)
Allocates a buffer.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
CRYPTOPP_DLL void CRYPTOPP_API AlignedDeallocate(void *ptr)
Frees a buffer allocated with AlignedAllocate.
Debugging and diagnostic assertions.
Crypto++ library namespace.