7#ifndef CORE_FXCRT_FX_MEMORY_H_
8#define CORE_FXCRT_FX_MEMORY_H_
25#include "core/fxcrt/compiler_specific.h"
27#if defined(COMPILER_MSVC)
40#define FX_Alloc(type, size)
41 static_cast<type*>(pdfium::internal::CallocOrDie(size, sizeof(type)))
42#define FX_Alloc2D(type, w, h)
43 static_cast<type*>(pdfium::internal::CallocOrDie2D(w, h, sizeof(type)))
44#define FX_Realloc(type, ptr, size)
45 static_cast<type*>(pdfium::internal::ReallocOrDie(ptr, size, sizeof(type)))
48#define FX_TryAlloc(type, size)
49 static_cast<type*>(pdfium::internal::Calloc(size, sizeof(type)))
50#define FX_TryRealloc(type, ptr, size)
51 static_cast<type*>(pdfium::internal::Realloc(ptr, size, sizeof(type)))
54#define FX_AllocUninit(type, size)
55 static_cast<type*>(pdfium::internal::AllocOrDie(size, sizeof(type)))
56#define FX_AllocUninit2D(type, w, h)
57 static_cast<type*>(pdfium::internal::AllocOrDie2D(w, h, sizeof(type)))
60#define FX_TryAllocUninit(type, size)
61 static_cast<type*>(pdfium::internal::Alloc(size, sizeof(type)))
62#define FX_TryAllocUninit2D(type, w, h)
63 static_cast<type*>(pdfium::internal::Alloc2D(w, h, sizeof(type)))
66#define FX_Free(ptr) pdfium::internal::Dealloc(ptr)
71#define FX_StringAlloc(type, size)
72 static_cast<type*>(pdfium::internal::StringAllocOrDie(size, sizeof(type)))
75#define FX_StringFree(ptr) pdfium::internal::StringDealloc(ptr)
77#ifndef V8_ENABLE_SANDBOX
97inline void FX_AlignedFree(
void* ptr) {
98#if defined(COMPILER_MSVC)
109void*
Alloc(size_t num_members, size_t member_size);
110void*
Alloc2D(size_t w, size_t h, size_t member_size);
111void*
AllocOrDie(size_t num_members, size_t member_size);
112void*
AllocOrDie2D(size_t w, size_t h, size_t member_size);
113void*
Calloc(size_t num_members, size_t member_size);
114void*
Realloc(
void* ptr, size_t num_members, size_t member_size);
115void*
CallocOrDie(size_t num_members, size_t member_size);
117void*
ReallocOrDie(
void* ptr, size_t num_members, size_t member_size);
121void*
StringAlloc(size_t num_members, size_t member_size);
133#define FX_STACK_ALLOCATED()
134 void* operator
new(size_t) = delete;
135 void* operator
new(size_t, void*) = delete
138template <
int N,
typename T>
139inline T FxAlignToBoundary(T size) {
140 static_assert(N > 0 && (N & (N - 1)) == 0,
"Not non-zero power of two");
141 return (size + (N - 1)) & ~(N - 1);
constexpr span(T(&array)[N]) noexcept
constexpr reverse_iterator rend() const noexcept
constexpr reverse_iterator rbegin() const noexcept
constexpr const_reverse_iterator crend() const noexcept
std::reverse_iterator< iterator > reverse_iterator
const span first(size_t count) const
typename std::remove_cv< T >::type value_type
span & operator=(const span &other) noexcept
constexpr const_iterator cbegin() const noexcept
constexpr const_iterator cend() const noexcept
constexpr const_reverse_iterator crbegin() const noexcept
const span last(size_t count) const
constexpr bool empty() const noexcept
constexpr size_t size() const noexcept
constexpr span(Container &container)
friend constexpr span< U > make_span(U *data, size_t size) noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator
const span subspan(size_t pos, size_t count=dynamic_extent) const
constexpr iterator begin() const noexcept
constexpr size_t size_bytes() const noexcept
constexpr span() noexcept=default
span(const Container &container)
constexpr span(std::array< T, N > &array) noexcept
constexpr T & back() const noexcept
constexpr span(const std::array< std::remove_cv_t< T >, N > &array) noexcept
constexpr T * data() const noexcept
constexpr T & front() const noexcept
constexpr span(const span &other) noexcept=default
UNSAFE_BUFFER_USAGE constexpr span(T *data, size_t size) noexcept
constexpr span(const span< U, M, R > &other)
T & operator[](size_t index) const noexcept
constexpr iterator end() const noexcept
#define UNSAFE_BUFFERS(...)
#define UNSAFE_BUFFER_USAGE
void CRYPT_MD5Finish(CRYPT_md5_context *context, pdfium::span< uint8_t, 16 > digest)
#define P(a, b, c, d, k, s, t)
void CRYPT_MD5Generate(pdfium::span< const uint8_t > data, pdfium::span< uint8_t, 16 > digest)
void CRYPT_ArcFourCryptBlock(pdfium::span< uint8_t > data, pdfium::span< const uint8_t > key)
void CRYPT_ArcFourSetup(CRYPT_rc4_context *context, pdfium::span< const uint8_t > key)
void CRYPT_MD5Update(CRYPT_md5_context *context, pdfium::span< const uint8_t > data)
void CRYPT_ArcFourCrypt(CRYPT_rc4_context *context, pdfium::span< uint8_t > data)
CRYPT_md5_context CRYPT_MD5Start()
void CRYPT_AESEncrypt(CRYPT_aes_context *ctx, pdfium::span< uint8_t > dest, pdfium::span< const uint8_t > src)
void CRYPT_AESSetIV(CRYPT_aes_context *ctx, const uint8_t *iv)
void CRYPT_AESDecrypt(CRYPT_aes_context *ctx, uint8_t *dest, const uint8_t *src, uint32_t size)
void CRYPT_AESSetKey(CRYPT_aes_context *ctx, const uint8_t *key, uint32_t keylen)
void CRYPT_SHA512Update(CRYPT_sha2_context *context, pdfium::span< const uint8_t > data)
void CRYPT_SHA384Update(CRYPT_sha2_context *context, pdfium::span< const uint8_t > data)
DataVector< uint8_t > CRYPT_SHA256Generate(pdfium::span< const uint8_t > data)
void CRYPT_SHA1Finish(CRYPT_sha1_context *context, pdfium::span< uint8_t, 20 > digest)
void CRYPT_SHA1Update(CRYPT_sha1_context *context, pdfium::span< const uint8_t > data)
void CRYPT_SHA512Finish(CRYPT_sha2_context *context, pdfium::span< uint8_t, 64 > digest)
DataVector< uint8_t > CRYPT_SHA384Generate(pdfium::span< const uint8_t > data)
void CRYPT_SHA384Start(CRYPT_sha2_context *context)
void CRYPT_SHA384Finish(CRYPT_sha2_context *context, pdfium::span< uint8_t, 48 > digest)
void CRYPT_SHA512Start(CRYPT_sha2_context *context)
DataVector< uint8_t > CRYPT_SHA1Generate(pdfium::span< const uint8_t > data)
void CRYPT_SHA256Start(CRYPT_sha2_context *context)
DataVector< uint8_t > CRYPT_SHA512Generate(pdfium::span< const uint8_t > data)
void CRYPT_SHA1Start(CRYPT_sha1_context *context)
void CRYPT_SHA256Finish(CRYPT_sha2_context *context, pdfium::span< uint8_t, 32 > digest)
void CRYPT_SHA256Update(CRYPT_sha2_context *context, pdfium::span< const uint8_t > data)
NOINLINE void FX_OutOfMemoryTerminate(size_t size)
void * FX_AlignedAlloc(size_t size, size_t alignment)
void FXMEM_DefaultFree(void *pointer)
void * FXMEM_DefaultAlloc(size_t byte_size)
void * FXMEM_DefaultCalloc(size_t num_elems, size_t byte_size)
void * FXMEM_DefaultRealloc(void *pointer, size_t new_size)
void * FX_ArrayBufferAllocate(size_t length)
void FX_DestroyMemoryAllocators()
void FX_InitializeMemoryAllocators()
void FX_ArrayBufferFree(void *data)
void * FX_ArrayBufferAllocateUninitialized(size_t length)
void * CallocOrDie2D(size_t w, size_t h, size_t member_size)
void * AllocOrDie2D(size_t w, size_t h, size_t member_size)
std::is_integral< decltype(std::declval< Container >().size())> ContainerHasIntegralSize
void * StringAllocOrDie(size_t num_members, size_t member_size)
void * Alloc(size_t num_members, size_t member_size)
IsSpanImpl< typename std::decay< T >::type > IsSpan
void * StringAlloc(size_t num_members, size_t member_size)
void * ReallocOrDie(void *ptr, size_t num_members, size_t member_size)
std::is_convertible< From *, To * > IsLegalSpanConversion
void * Realloc(void *ptr, size_t num_members, size_t member_size)
IsStdArrayImpl< typename std::decay< T >::type > IsStdArray
void StringDealloc(void *ptr)
void * AllocOrDie(size_t num_members, size_t member_size)
void * Alloc2D(size_t w, size_t h, size_t member_size)
void * Calloc(size_t num_members, size_t member_size)
void * CallocOrDie(size_t num_members, size_t member_size)
constexpr span< T > make_span(T(&array)[N]) noexcept
span< char > as_writable_chars(span< T, N, P > s) noexcept
span< const uint8_t > as_bytes(span< T, N, P > s) noexcept
constexpr size_t dynamic_extent
static constexpr span< T > span_from_ref(T &single_object) noexcept
static constexpr span< const uint8_t > byte_span_from_ref(const T &single_object) noexcept
UNSAFE_BUFFER_USAGE constexpr span< T > make_span(T *data, size_t size) noexcept
span< const uint8_t > as_byte_span(T &&arg)
span< const char > as_chars(span< T, N, P > s) noexcept
span< const uint8_t > as_byte_span(const T &arg)
UNOWNED_PTR_EXCLUSION T * DefaultSpanInternalPtr
span< uint8_t > as_writable_bytes(span< T, N, P > s) noexcept
constexpr span< T > make_span(std::array< T, N > &array) noexcept
constexpr span< T > make_span(Container &container)
constexpr span< uint8_t > as_writable_byte_span(T &&arg)
IMMEDIATE_CRASH_ALWAYS_INLINE void ImmediateCrash()
static constexpr span< uint8_t > byte_span_from_ref(T &single_object) noexcept
constexpr span< T > make_span(const Container &container)
#define __has_attribute(x)
std::array< uint32_t, kMaxNb > iv
std::array< uint32_t, kSchedSize > invkeysched
static constexpr int kMaxNr
static constexpr int kSchedSize
static constexpr int kMaxNb
std::array< uint32_t, kSchedSize > keysched
std::array< uint32_t, 4 > state
std::array< uint32_t, 2 > total
std::array< int32_t, kPermutationLength > m
static constexpr int32_t kPermutationLength
std::array< uint32_t, 5 > h
std::array< uint8_t, 64 > block
std::array< uint64_t, 8 > state
void operator()(void *ptr) const
FxPartitionAllocAllocator< U, Alloc, Free > other
pointer allocate(size_type n, const void *hint=0)
void deallocate(pointer p, size_type n)
const_pointer address(const_reference x) const noexcept
FxPartitionAllocAllocator() noexcept=default
size_type max_size() const noexcept
~FxPartitionAllocAllocator()=default
pointer address(reference x) const noexcept
FxPartitionAllocAllocator(const FxPartitionAllocAllocator< U, Alloc, Free > &other) noexcept
bool operator!=(const FxPartitionAllocAllocator &that)
void construct(U *p, Args &&... args)
const T & const_reference
bool operator==(const FxPartitionAllocAllocator &that)
FxPartitionAllocAllocator(const FxPartitionAllocAllocator &other) noexcept=default
#define UNOWNED_PTR_EXCLUSION