chsvlib
chsv helper source code
chsvmem.h File Reference

The file provides interfaces manage memory. More...

#include "chsvsal.h"
#include "chsverr.h"
#include "chsvprintf.h"

Classes

struct  DefaultResourceHandleChecker< HANDLE_TYPE >
 The default functor for checking if a handle to a resource should be closed by an instance of the AutoResource owning the handle. More...
 
class  AutoResource< HANDLE_TYPE, CCloser, IsHandleValidClass >
 Manages the specified resource handles, providing a limited garbage-collection facility. More...
 
struct  C_auto_ptr< element_type, DELETER, pFree >
 A helper class for defining pointers managed automatically with a limited garbage-collecting facility implemented over the functions of the Chusov::Memory namespace. More...
 
struct  AutoData< ValueType >
 A template of a class specifying std::unique_ptr to manage pointers allocated using one of the allocation functions of the chsvmem.h header, such as AllocateData or AllocateString, automatically deallocating memory pointed to by managed pointers when necessary. pointers using the FreeData function. More...
 
struct  AutoDataSec< ValueType >
 A template of a class specifying std::unique_ptr to manage pointers to sensitive data allocated using one of the allocation functions of the chsvmem.h header, such as AllocateData or AllocateString, deallocating memory, pointed to by the managed pointers, using the SecureFreeData function randomizing data before the actual deallocation. More...
 
struct  raw_delete_t< element_t >
 A type of a deleter object used with smart pointers to a raw memory block allocated using the global ::operator new function. When the managed memory is released these smart pointers call ::operator delete to perform the cleanup. More...
 
struct  raw_delete_t< element_t >::rebind< U >
 Defines an instance of the deleter template for other types of values. More...
 

Namespaces

 Chusov
 Basic chsvlib namespace.
 
 Chusov::Memory
 A namespace of functions and components used to work with memory.
 

Macros

#define MEMORY_BEGIN   namespace Memory {
 Defines the beginning of the Chusov::Memory namespace without defining the encapsulating namespace. More...
 
#define MEMORY_END   }
 Defines the end of the Chusov::Memory namespace. More...
 
#define GUID_LENGTH   36
 A length of a UUID number represented as a string of format "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" using hexadecimal digits excluding the terminating 0.
 

Functions

Memory allocation functions

Portable allocation functions

void * AllocateData (std::size_t cb) noexcept
 Allocates a memory buffer of the specified size and returns a pointer to it. More...
 
bool FreeData (void *pData) noexcept
 Frees memory occupied by the specified buffer which had been allocated using one of the Allocate* functions declared in the Chusov::Memory namespace. More...
 
std::size_t DataSize (const void *pData) noexcept
 Returns a size of memory pointed by the specified parameter, in bytes. More...
 
bool SecureFreeData (volatile void *pData) noexcept
 Randomizes and frees memory occupied by the specified buffer allocated using one of the Allocate* functions of the Chusov::Memory namespace. It is designed to be a more secure version of FreeData. More...
 

Memory processing

Basic memory processing

#define BYTESWAP_UINT16(x)   (((NS_STD uint16_t) (x) << 8) | (((NS_STD uint16_t) (x)) >> 8))
 Performs a byte swapping in a 2-byte integer variable to transform values between Little-Endian and Big-Endian formats. More...
 
#define BYTESWAP_UINT32(x)   (((NS_STD uint32_t) (NS_STD uint8_t) (x) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (NS_STD uint64_t) (NS_STD uint8_t) ((NS_STD uint32_t) (x) >> 24))
 Performs a byte swapping in a 4-byte integer variable to transform values between Little-Endian and Big-Endian formats. More...
 
#define BYTESWAP_UINT64(x)   (((NS_STD uint64_t) BYTESWAP_UINT32((NS_STD uint32_t) (x)) << 32) | (NS_STD uint64_t) BYTESWAP_UINT32((NS_STD uint32_t) ((NS_STD uint64_t) (x) >> 32)))
 Performs a byte swapping in a 8-byte integer variable to transform values between Little-Endian and Big-Endian formats. More...
 
#define INTEGERWORD_MAX   UINTPTR_MAX
 The greatest value of the IntegerWord type.
 
#define chsv_fast_bswap16(n)   depends_on_target_platform
 Inverses the current byte order in a 16-bit integral parameter. More...
 
#define chsv_fast_bswap32(n)   depends_on_target_platform
 Inverses the current byte order in a 32-bit integral parameter. More...
 
#define chsv_fast_bswap64(n)   depends_on_target_platform
 Inverses the current byte order in a 64-bit integral parameter. More...
 
#define chsv_fast_bswap_uintptr(n)   depends_on_target_platform
 Inverses the current byte order in an integer holding a pointer. More...
 
#define chsv_fast_bswap_iwrd(n)   depends_on_target_platform
 Inverses the current byte order in an integral word. More...
 
typedef std::uintptr_t IntegerWord
 A generic alias for an unsigned integer machine word.
 
constexpr auto mirror_byte = implementation
 Resolves to a constexpr array containing a table of byte values which are mirror-bit reflections of their positions in the array. More...
 
void byte_swap_inplace (void *pBuf, std::size_t cbBuf) noexcept
 Inverses an order of bytes in a buffer in place. More...
 
void byte_swap (void *pResult, const void *pApi, std::size_t cbApi) noexcept
 Inverses an order of bytes and writes the result to the destination buffer. More...
 
template<class T >
constexpr T byte_swap (T x) noexcept
 Swaps bytes of the specified object of the standard-layout type T. More...
 
template<class T >
fast_bswap (const T &datum) noexcept
 Performs fast inversion of a byte sequence within a datum using processor intrinsics, if possible. More...
 
template<class T >
constexpr auto mirror_bits (T val) noexcept
 Inverts a bit order of an argument. More...
 
void mirror_bits_copy (void *restrict pResult, const void *restrict pApi, std::size_t cbApi) noexcept
 Yields a copy of a vector with the inverse bit order. More...
 
void mirror_bits_inplace (void *pBuf, std::size_t cbBuf) noexcept
 Inverts a bit order within a vector. More...
 
void mirror_bits (void *pResult, const void *pApi, std::size_t cbApi) noexcept
 Inverts a bit order of data and writes the result to a possibly different buffer. More...
 
template<class T >
constexpr auto mirror_bits_kbo (T val) noexcept
 Inverts a bit order of an argument but keeps its byte order unchanged. More...
 
void mirror_bits_kbo_copy (void *restrict pResult, const void *restrict pApi, std::size_t cbApi) noexcept
 Inverts bits of data keeping the byte order and stores the result to an output buffer. More...
 
void mirror_bits_kbo_inplace (void *pBuf, std::size_t cbBuf) noexcept
 Inverts a bit order within a vector keeping its byte order unchanged. More...
 
void mirror_bits_kbo (void *pResult, const void *pApi, std::size_t cbApi) noexcept
 Inverts a bit order of data keeping its byte order and writes the result to a possibly different buffer. More...
 
void memlsh_LE_copy (void *restrict pResult, const void *restrict pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Bit-shifts a long integer specified by a vector of bytes in the Little-Endian order to the left and copies the result into a separate output buffer. More...
 
void memlsh_LE_inplace (void *pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Performs an in-place bit-shift of a long integer specified by a vector of bytes in the Little-Endian order to the left. More...
 
void memlsh_LE (void *pResult, std::size_t cbResult, const void *pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Performs a linear bit shift of data representing an unsigned arbitrary precision integer in the Little-Endian format to the left. More...
 
void memrsh_LE_copy (void *restrict pResult, const void *restrict pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Bit-shifts a long unsigned integer specified by a vector of bytes in the Little-Endian order to the right and copies the result into a separate output buffer. More...
 
void memrsh_LE_inplace (void *pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Performs an in-place bit-shift of a long integer specified by a vector of bytes in the Little-Endian order to the right. More...
 
void memrsh_LE (void *pResult, std::size_t cbResult, const void *pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Performs a linear bit shift of data representing an unsigned arbitrary precision integer in the Little-Endian format to the right. More...
 
void memlsh_BE_copy (void *restrict pResult, const void *restrict pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Bit-shifts a long integer specified by a vector of bytes in the Big-Endian order to the left and copies the result into a separate output buffer. More...
 
void memlsh_BE_inplace (void *pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Performs an in-place bit-shift of a long integer specified by a vector of bytes in the Big-Endian order to the left. More...
 
void memlsh_BE (void *pResult, std::size_t cbResult, const void *pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Performs a linear bit shift of data representing an unsigned arbitrary precision integer in the Big-Endian format to the left. More...
 
void memrsh_BE_copy (void *restrict pResult, const void *restrict pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Bit-shifts a long integer specified by a vector of bytes in the Big-Endian byte order to the right and copies the result into a separate output buffer. More...
 
void memrsh_BE_inplace (void *pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Performs an inplace bit-shift of a long integer specified by a vector of bytes in the Big-Endian order to the right. More...
 
void memrsh_BE (void *pResult, std::size_t cbResult, const void *pValue, std::size_t cbValue, std::size_t nShift) noexcept
 Performs a linear bit shift of data representing an unsigned arbitrary precision integer in the Big-Endian format to the right. More...
 
void memand_copy (void *restrict pDest, const void *restrict pSrc1, const void *restrict pSrc2, std::size_t cbSrc) noexcept
 Computes bitwise AND of two arbitrary precision integers and copies the resulting integer into a separate output buffer. More...
 
void memand_inplace (void *pSrcDest, const void *pSrc2, std::size_t cbSrcDest) noexcept
 Computes bitwise AND of two arbitrary precision integers and places the result into a buffer of one of the operands. More...
 
void memand_LE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 The generic form of bitwise AND of two operands specified in the Little-Endian byte order. More...
 
void memand_BE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 The generic form of bitwise AND of two operands specified in Big-Endian byte order. More...
 
void memor_copy (void *restrict pDest, const void *restrict pSrc1, const void *restrict pSrc2, std::size_t cbSrc) noexcept
 Computes bitwise OR of two arbitrary precision integers and copies the resulting integer into a separate output buffer. More...
 
void memor_inplace (void *pSrcDest, const void *pSrc2, std::size_t cbSrcDest) noexcept
 Computes bitwise OR of two arbitrary precision integers and places the result into a buffer of one of the operands. More...
 
void memor_LE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 The generic form of bitwise OR of two operands specified in the Little-Endian byte order. More...
 
void memor_BE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 The generic form of bitwise OR of two operands specified in Big-Endian byte order. More...
 
void memxor_copy (void *restrict pDest, const void *restrict pSrc1, const void *restrict pSrc2, std::size_t cbSrc) noexcept
 Computes bitwise XOR of two arbitrary precision integers and copies the resulting integer into a separate output buffer. More...
 
void memxor_inplace (void *pSrcDest, const void *pSrc2, std::size_t cbSrcDest) noexcept
 Computes bitwise OR of two arbitrary precision integers and places the result into a buffer of one of the operands. More...
 
void memxor_LE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 The generic form of bitwise XOR of two operands specified in the Little-Endian byte order. More...
 
void memxor_BE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 The generic form of bitwise XOR of two operands specified in Big-Endian byte order. More...
 
void memandnot_copy (void *restrict pDest, const void *restrict pSrc1, const void *restrict pSrc2, std::size_t cbSrc) noexcept
 Computes bitwise NOT of an arbitrary-precision integer, then computes bitwise AND of the result with another arbitrary-precision integer and copies the final result into a separate destination buffer. More...
 
void memandnot_inplace (void *pSrcDest, const void *pSrc2, std::size_t cbSrcDest) noexcept
 Computes bitwise NOT of an arbitrary-precision integer, then computes bitwise AND of the result with another arbitrary-precision integer producing the final result written in place of the first integer. More...
 
void memandnot_LE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 A generic form of bitwise NOT-AND of an arbitrary precision integer with another integer both of which are specified with byte vectors in the Little-Endian order. More...
 
void memandnot_BE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 A generic form of bitwise NOT-AND of an arbitrary precision integer with another integer both of which are specified with byte vectors in the Big-Endian order. More...
 
void memornot_copy (void *restrict pDest, const void *restrict pSrc1, const void *restrict pSrc2, std::size_t cbSrc) noexcept
 Computes bitwise NOT of an arbitrary-precision integer, then computes bitwise OR of the result with another arbitrary-precision integer and copies the final result into a separate destination buffer. More...
 
void memornot_inplace (void *pSrcDest, const void *pSrc2, std::size_t cbSrcDest) noexcept
 Computes bitwise NOT of an arbitrary-precision integer, then computes bitwise OR of the result with another arbitrary-precision integer producing the final result written in place of the first integer. More...
 
void memornot_LE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 A generic form of bitwise NOT-OR of an arbitrary precision integer with another integer both of which are specified with byte vectors in the Little-Endian order. More...
 
void memornot_BE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 A generic form of bitwise NOT-OR of an arbitrary precision integer with another integer both of which are specified with byte vectors in the Big-Endian order. More...
 
void memxornot_copy (void *restrict pDest, const void *restrict pSrc1, const void *restrict pSrc2, std::size_t cbSrc) noexcept
 Computes bitwise NOT of an arbitrary-precision integer, then computes bitwise XOR of the result with another arbitrary-precision integer and copies the final result into a separate destination buffer. More...
 
void memxornot_inplace (void *pSrcDest, const void *pSrc2, std::size_t cbSrcDest) noexcept
 Computes bitwise NOT of an arbitrary-precision integer, then computes bitwise XOR of the result with another arbitrary-precision integer producing the final result written in place of the first integer. More...
 
void memxornot_LE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 A generic form of bitwise NOT-XOR of an arbitrary precision integer with another integer both of which are specified with byte vectors in the Little-Endian order. More...
 
void memxornot_BE (void *pDest, std::size_t cbDest, const void *pSrc1, std::size_t cbSrc1, const void *pSrc2, std::size_t cbSrc2) noexcept
 A generic form of bitwise NOT-XOR of an arbitrary precision integer with another integer both of which are specified with byte vectors in the Big-Endian order. More...
 
void memnot_copy (void *restrict pDest, const void *restrict pSrc, std::size_t cbSrc) noexcept
 Computes bitwise NOT of an arbitrary-precision integer and writes the result into a separate output buffer. More...
 
void memnot_inplace (void *pSrcDest, std::size_t cbSrcDest) noexcept
 Computes bitwise NOT of value in place of its buffer. More...
 
void memnot_LE (void *pDest, std::size_t cbDest, const void *pSrc, std::size_t cbSrc) noexcept
 The generic form of bitwise NOT of an arbitrary-precision value specified in the Little-Endian byte order. More...
 
void memnot_BE (void *pDest, std::size_t cbDest, const void *pSrc, std::size_t cbSrc) noexcept
 The generic form of bitwise NOT of an arbitrary-precision value specified in the Big-Endian byte order. More...
 
bool memincr_LE_copy (void *restrict pDest, const void *restrict pSrc, std::size_t cbData) noexcept
 Increments an arbitrary precision integer specified by a vector of bytes in the Little-Endian order, writes the result to a separate memory buffer and returns the carry flag. More...
 
bool memincr_LE_inplace (void *pData, std::size_t cbData) noexcept
 Increments an arbitrary precision integer specified by a vector of bytes in the Little-Endian order in place and returns the carry flag. More...
 
bool memincr_LE (void *pDest, std::size_t cbDest, const void *pSrc, std::size_t cbSrc) noexcept
 Increments an arbitrary precision integer specified by a vector of bytes in the Little-Endian byte order doing it in place or writing the result into a separate buffer with zero-extension or contraction to fit the buffer and returns the resulting carry flag. More...
 
bool memincr_BE_copy (void *restrict pDest, const void *restrict pSrc, std::size_t cbData) noexcept
 Increments an arbitrary precision integer specified by a vector of bytes in the Big-Endian order, writes the result to a separate memory buffer and returns the carry flag. More...
 
bool memincr_BE_inplace (void *pData, std::size_t cbData) noexcept
 Increments an arbitrary precision integer specified by a vector of bytes in the Big-Endian order in place and returns the carry flag. More...
 
bool memincr_BE (void *pDest, std::size_t cbDest, const void *pSrc, std::size_t cbSrc) noexcept
 Increments an arbitrary precision integer specified by a vector of bytes in the Big-Endian byte order doing it in place or writing the result into a separate buffer with zero-extension or contraction to fit the buffer and returns the resulting carry flag. More...
 
bool memdecr_LE_inplace (void *pData, std::size_t cbData) noexcept
 Decrements an arbitrary precision integer specified by a vector of bytes in the Little-Endian order in place and returns the borrow bit. More...
 
bool memdecr_LE_copy (void *restrict pDest, const void *restrict pSrc, std::size_t cbData) noexcept
 Decrements an arbitrary precision integer specified by a vector of bytes in the Little-Endian order, writes the result to a separate memory buffer and returns the borrow bit. More...
 
bool memdecr_LE (void *pDest, std::size_t cbDest, const void *pSrc, std::size_t cbSrc) noexcept
 Decrements an arbitrary precision integer specified by a vector of bytes in the Little-Endian byte order doing it in place or writing the result into a separate buffer with zero-extension or contraction to fit the buffer and returns the resulting borrow bit. More...
 
bool memdecr_BE_copy (void *restrict pDest, const void *restrict pSrc, std::size_t cbData) noexcept
 Decrements an arbitrary precision integer specified by a vector of bytes in the Big-Endian order, writes the result to a separate memory buffer and returns the borrow bit. More...
 
bool memdecr_BE_inplace (void *pData, std::size_t cbData) noexcept
 Decrements an arbitrary precision integer specified by a vector of bytes in the Big-Endian order in place and returns the borrow bit. More...
 
bool memdecr_BE (void *pDest, std::size_t cbDest, const void *pSrc, std::size_t cbSrc) noexcept
 Decrements an arbitrary precision integer specified by a vector of bytes in the Big-Endian byte order doing it in place or writing the result into a separate buffer with zero-extension or contraction to fit the buffer and returns the resulting borrow bit. More...
 
bool memneg_LE_copy (void *restrict pDest, const void *restrict pSrc, std::size_t cbData) noexcept
 Calculates an additive inversion of an arbitrary-precision integer given by a vector of bytes in the Little-Endian order and writes it to a separate buffer returning the value of the highest bit of the result. More...
 
bool memneg_LE_inplace (void *pData, std::size_t cbData) noexcept
 Replaces an arbitrary-precision integer given by a vector of bytes in the Little-Endian order with its additive inversion returning the value of the highest bit of the result. More...
 
bool memneg_LE (void *pDest, std::size_t cbDest, const void *pSrc, std::size_t cbSrc) noexcept
 Zero-extends or contracts an arbitrary-precision integer given in the Little-Endian byte order, then computes an additive inversion of it in a separate of the same destination buffer returning a value of the highest bit of the result. More...
 
bool memneg_BE_copy (void *restrict pDest, const void *restrict pSrc, std::size_t cbData) noexcept
 Calculates an additive inversion of an arbitrary-precision integer given by a vector of bytes in the Big-Endian order and writes it to a separate buffer returning the value of the highest bit of the result. More...
 
bool memneg_BE_inplace (void *pData, std::size_t cbData) noexcept
 Replaces an arbitrary-precision integer given by a vector of bytes in the Big-Endian order with its additive inversion returning the value of the highest bit of the result. More...
 
bool memneg_BE (void *pDest, std::size_t cbDest, const void *pSrc, std::size_t cbSrc) noexcept
 Zero-extends or contracts an arbitrary-precision integer given in the Big-Endian byte order, then computes an additive inversion of it in a separate of the same destination buffer returning a value of the highest bit of the result. More...
 
bool memadd_LE_copy (void *restrict pResult, const void *restrict pX, const void *restrict pY, std::size_t cb) noexcept
 Performs an addition of two arbitrary-precision integers given in the Little-Endian byte order and of the same size and writes the result into a separate output buffer. More...
 
bool memadd_LE_inplace (void *pResult, const void *pAddend, std::size_t cb) noexcept
 Replaces an integer given by a vector of bytes in the Little-Endian order with the result of its addition with another integer. More...
 
bool memadd_LE (void *pResult, std::size_t cbResult, const void *pX, std::size_t cbX, const void *pY, std::size_t cbY) noexcept
 Performs an addition of two Little-Endian arbitrary-precision integers and returns the carry flag. More...
 
bool memadd_BE_copy (void *restrict pResult, const void *restrict pX, const void *restrict pY, std::size_t cb) noexcept
 Performs an addition of two arbitrary-precision integers given in the Big-Endian byte order and of the same size and writes the result into a separate output buffer. More...
 
bool memadd_BE_inplace (void *pResult, const void *pAddend, std::size_t cb) noexcept
 Replaces an integer given by a vector of bytes in the Big-Endian order with the result of its addition with another integer. More...
 
bool memadd_BE (void *pResult, std::size_t cbResult, const void *pX, std::size_t cbX, const void *pY, std::size_t cbY) noexcept
 Performs an addition of two Big-Endian arbitrary-precision integers and returns the carry flag. More...
 
bool memsub_LE_copy (void *restrict pResult, const void *restrict pX, const void *restrict pY, std::size_t cb) noexcept
 Computes a difference between two distinct arbitrary-precision integers given in the Little-Endian byte order, writes the difference to a separate buffer and returns the resulting borrow bit. More...
 
bool memsub_LE_inplace (void *pResult, const void *pMinuend, std::size_t cb) noexcept
 Subtracts an arbitrary-precision integer from another arbitrary-precision integer in place of the latter and returns the resulting borrow bit. The operands and the result are considered to be in the Little-Endian byte order. More...
 
bool memnegsub_LE_inplace (void *pResult, const void *pSubtrahend, std::size_t cb) noexcept
 Subtracts an arbitrary-precision integer from another arbitrary-precision integer in place of the former and returns the resulting borrow bit. The operands and the result are considered to be in the Little-Endian byte order. More...
 
bool memsub_LE (void *pResult, std::size_t cbResult, const void *pX, std::size_t cbX, const void *pY, std::size_t cbY) noexcept
 Computes a difference between two arbitrary-precision integers specified with vectors in the Little-Endian byte order and returns the borrow bit. More...
 
bool memsub_BE_copy (void *restrict pResult, const void *restrict pX, const void *restrict pY, std::size_t cb) noexcept
 Computes a difference between two distinct arbitrary-precision integers given in the Big-Endian byte order, writes the difference to a separate buffer and returns the resulting borrow bit. More...
 
bool memsub_BE_inplace (void *pResult, const void *pMinuend, std::size_t cb) noexcept
 Subtracts an arbitrary-precision integer from another arbitrary-precision integer in place of the latter and returns the resulting borrow bit. The operands and the result are considered to be in the Big-Endian byte order. More...
 
bool memnegsub_BE_inplace (void *pResult, const void *pSubtrahend, std::size_t cb) noexcept
 Subtracts an arbitrary-precision integer from another arbitrary-precision integer in place of the former and returns the resulting borrow bit. The operands and the result are considered to be in the Big-Endian byte order. More...
 
bool memsub_BE (void *pResult, std::size_t cbResult, const void *pX, std::size_t cbX, const void *pY, std::size_t cbY) noexcept
 Computes a difference between two arbitrary-precision integers specified with vectors in the Big-Endian byte order and returns the borrow bit. More...
 
int memcmp_LE (const void *pX, std::size_t cbX, const void *pY, std::size_t cbY) noexcept
 Compares two arbitrary-precision integers specified with vectors of bytes in the Little-Endian order. More...
 
int memcmp_BE (const void *pX, std::size_t cbX, const void *pY, std::size_t cbY) noexcept
 Compares two arbitrary-precision integers specified with vectors of bytes in the Big-Endian order. More...
 
void memfmadd_LE (void *restrict pResult, std::size_t cbResult, const void *restrict pX, std::size_t cbX, const void *restrict pY, std::size_t cbY) noexcept
 Computes fused multiply-add multiplying two arbitrary-precision integers and adding them to a third integer writing the result in place of the latter. All integers are specified by vectors of bytes in the Little-Endian order. More...
 
void memfmsub_LE (void *restrict pResult, std::size_t cbResult, const void *restrict pX, std::size_t cbX, const void *restrict pY, std::size_t cbY) noexcept
 Performs fused multiplication of two arbitrary-precision integers and a subtraction of the product from another arbitrary-precision integer in place. All integers are specified with vectors of bytes in the Little-Endian order. More...
 
void memfmadd_BE (void *restrict pResult, std::size_t cbResult, const void *restrict pX, std::size_t cbX, const void *restrict pY, std::size_t cbY) noexcept
 Computes fused multiply-add multiplying two arbitrary-precision integers and adding them to a third integer writing the result in place of the latter. All integers are specified by vectors of bytes in the Big-Endian order. More...
 
void memfmsub_BE (void *restrict pResult, std::size_t cbResult, const void *restrict pX, std::size_t cbX, const void *restrict pY, std::size_t cbY) noexcept
 Performs fused multiplication of two arbitrary-precision integers and a subtraction of the product from another arbitrary-precision integer in place. All integers are specified with vectors of bytes in the Big-Endian order. More...
 
void memmul_LE (void *restrict pResult, std::size_t cbResult, const void *restrict pX, std::size_t cbX, const void *restrict pY, std::size_t cbY) noexcept
 Multiplies two arbitrary-precision integers specified by vectors of bytes in the Little-Endian byte order. More...
 
void memmul_BE (void *restrict pResult, std::size_t cbResult, const void *restrict pX, std::size_t cbX, const void *restrict pY, std::size_t cbY) noexcept
 Multiplies two arbitrary-precision integers specified by vectors of bytes in the Big-Endian byte order. More...
 
chsverror_t memdiv_LE (const void *restrict pDividend, std::size_t cbDividend, const void *restrict pDivisor, std::size_t cbDivisor, void *restrict pQuotient, std::size_t cbQuotient, void *restrict pRemainder, std::size_t cbRemainder) noexcept
 Performs Euclidean division of two arbitrary-precision integers specified with vectors of bytes in the Little-Endian order and produces an arbitrary-precision quotient and remainder. More...
 
chsverror_t memdiv_BE (const void *restrict pDividend, std::size_t cbDividend, const void *restrict pDivisor, std::size_t cbDivisor, void *restrict pQuotient, std::size_t cbQuotient, void *restrict pRemainder, std::size_t cbRemainder) noexcept
 Performs Euclidean division of two arbitrary-precision integers specified with vectors of bytes in the Big-Endian order and produces an arbitrary-precision quotient and remainder. More...
 
template<class T >
constexpr std::uint8_t bsf (T val) noexcept
 Returns an index of the rightmost (least significant) nonzero bit of an integer. More...
 
template<class T >
constexpr std::uint8_t bsr (T val) noexcept
 Returns an index of the leftmost (most significant) nonzero bit of an integer. More...
 
unsigned long long GetDefaultSeed () noexcept
 Returns an 8 byte random value that can be used in non secure random operations. More...
 
unsigned long long RandomizeMemory_LE (unsigned long long nSeed, void *pMemory, std::size_t cbMemory) noexcept
 Randomize a memory buffer. More...
 
unsigned long long RandomizeMemory_BE (unsigned long long nSeed, void *pMemory, std::size_t cbMemory) noexcept
 Randomize a memory buffer writing the least significant byte of a random value to the end of the buffer. More...
 
unsigned long long RandomizeMemory (unsigned long long nSeed, void *pMemory, std::size_t cbMemory) noexcept
 Randomize a memory buffer. More...
 

Detailed Description

The file provides interfaces manage memory.