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 std::new_handler newHandler = std::set_new_handler(NULLPTR);
32 std::set_new_handler(newHandler);
37 throw std::bad_alloc();
43#if defined(CRYPTOPP_MM_MALLOC_AVAILABLE)
44 while ((p = (
byte *)_mm_malloc(size, 16)) == NULLPTR)
45#elif defined(CRYPTOPP_MEMALIGN_AVAILABLE)
46 while ((p = (
byte *)memalign(16, size)) == NULLPTR)
47#elif defined(CRYPTOPP_MALLOC_ALIGNMENT_IS_16)
48 while ((p = (
byte *)malloc(size)) == NULLPTR)
49#elif defined(CRYPTOPP_POSIX_MEMALIGN_AVAILABLE)
50 while (posix_memalign(
reinterpret_cast<void**
>(&p), 16, size) != 0)
52 while ((p = (
byte *)malloc(size + 16)) == NULLPTR)
56#ifdef CRYPTOPP_NO_ALIGNED_ALLOC
57 size_t adjustment = 16-((size_t)p%16);
60 p[-1] = (
byte)adjustment;
78#ifdef CRYPTOPP_MM_MALLOC_AVAILABLE
80#elif defined(CRYPTOPP_NO_ALIGNED_ALLOC)
81 p = (
byte *)p - ((
byte *)p)[-1];
92 while ((p = malloc(size)) == NULLPTR)
Functions for allocating aligned buffers.
CRYPTOPP_DLL void AlignedDeallocate(void *ptr)
Frees a buffer allocated with AlignedAllocate.
CRYPTOPP_DLL void CallNewHandler()
Attempts to reclaim unused memory.
CRYPTOPP_DLL void * UnalignedAllocate(size_t size)
Allocates a buffer.
CRYPTOPP_DLL void UnalignedDeallocate(void *ptr)
Frees a buffer allocated with UnalignedAllocate.
CRYPTOPP_DLL void * AlignedAllocate(size_t size)
Allocates a buffer on 16-byte boundary.
Library configuration file.
unsigned char byte
8-bit unsigned datatype
Utility functions for the Crypto++ library.
bool IsAlignedOn(const void *ptr, unsigned int alignment)
Determines whether ptr is aligned to a minimum value.
Crypto++ library namespace.
Debugging and diagnostic assertions.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.