Security Scol plugin
|
Functions for allocating aligned buffers. More...
Go to the source code of this file.
Functions | |
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. | |
CRYPTOPP_DLL void CRYPTOPP_API | AlignedDeallocate (void *ptr) |
Frees a buffer allocated with AlignedAllocate. | |
CRYPTOPP_DLL void *CRYPTOPP_API | UnalignedAllocate (size_t size) |
Allocates a buffer. | |
CRYPTOPP_DLL void CRYPTOPP_API | UnalignedDeallocate (void *ptr) |
Frees a buffer allocated with UnalignedAllocate. | |
Functions for allocating aligned buffers.
Definition in file allocate.h.
CRYPTOPP_DLL void *CRYPTOPP_API AlignedAllocate | ( | size_t | size | ) |
Allocates a buffer on 16-byte boundary.
size | the size of the buffer |
AlignedAllocate is primarily used when the data will be processed by SSE, NEON, ARMv8 or PowerPC instructions. The assembly language routines rely on the alignment. If the alignment is not respected, then a SIGBUS could be generated on Unix and Linux, and an EXCEPTION_DATATYPE_MISALIGNMENT could be generated on Windows.
Formerly, AlignedAllocate and AlignedDeallocate were only available on certain platforms when CRYTPOPP_DISABLE_ASM was not in effect. However, Android and iOS debug simulator builds got into a state where the aligned allocator was not available and caused link failures.
Definition at line 43 of file allocate.cpp.
CRYPTOPP_DLL void CRYPTOPP_API AlignedDeallocate | ( | void * | ptr | ) |
Frees a buffer allocated with AlignedAllocate.
ptr | the buffer to free |
Definition at line 72 of file allocate.cpp.
CRYPTOPP_DLL void CRYPTOPP_API CallNewHandler | ( | ) |
Attempts to reclaim unused memory.
bad_alloc |
In the normal course of running a program, a request for memory normally succeeds. If a call to AlignedAllocate or UnalignedAllocate fails, then CallNewHandler is called in n effort to recover. Internally, CallNewHandler calls set_new_handler(nullptr) in an effort to free memory. There is no guarantee CallNewHandler will be able to obtain more memory so an allocation succeeds. If the call to set_new_handler fails, then CallNewHandler throws a bad_alloc exception.
bad_alloc | on failure |
Definition at line 28 of file allocate.cpp.
CRYPTOPP_DLL void *CRYPTOPP_API UnalignedAllocate | ( | size_t | size | ) |
Allocates a buffer.
size | the size of the buffer |
Definition at line 92 of file allocate.cpp.
CRYPTOPP_DLL void CRYPTOPP_API UnalignedDeallocate | ( | void * | ptr | ) |
Frees a buffer allocated with UnalignedAllocate.
ptr | the buffer to free |
Definition at line 100 of file allocate.cpp.