10#ifndef CRYPTOPP_IMPORTS
18#if defined(CRYPTOPP_MEMALIGN_AVAILABLE) || defined(CRYPTOPP_MM_MALLOC_AVAILABLE) || defined(QNX)
22#if defined(CRYPTOPP_POSIX_MEMALIGN_AVAILABLE)
26NAMESPACE_BEGIN(CryptoPP)
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();
43void * AlignedAllocate(
size_t size)
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);
61 CRYPTOPP_ASSERT(adjustment > 0);
63 p[-1] = (
byte)adjustment;
72void AlignedDeallocate(
void *p)
81#ifdef CRYPTOPP_MM_MALLOC_AVAILABLE
83#elif defined(CRYPTOPP_NO_ALIGNED_ALLOC)
84 p = (
byte *)p - ((
byte *)p)[-1];
92void * UnalignedAllocate(
size_t size)
95 while ((p = malloc(size)) == NULLPTR)
100void UnalignedDeallocate(
void *p)
Functions for allocating aligned buffers.
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.
Debugging and diagnostic assertions.