Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cfx_v8_array_buffer_allocator.cpp
Go to the documentation of this file.
1
// Copyright 2021 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7
#
include
"fxjs/cfx_v8_array_buffer_allocator.h"
8
9
#
include
"core/fxcrt/fx_memory.h"
10
11
CFX_V8ArrayBufferAllocator::
CFX_V8ArrayBufferAllocator
() =
default
;
12
13
CFX_V8ArrayBufferAllocator::~
CFX_V8ArrayBufferAllocator
() =
default
;
14
15
// NOTE: Under V8 sandbox mode, defer NewDefaultAllocator() call until
16
// first use, since V8 must be initialized first for it to succeed, but
17
// we need the allocator in order to initialize V8.
18
19
void
* CFX_V8ArrayBufferAllocator::
Allocate
(size_t length) {
20
if
(length > kMaxAllowedBytes)
21
return
nullptr
;
22
#
ifdef
V8_ENABLE_SANDBOX
23
if
(!wrapped_) {
24
wrapped_.reset(v8::ArrayBuffer::Allocator::NewDefaultAllocator());
25
}
26
return
wrapped_->Allocate(length);
27
#
else
// V8_ENABLE_SANDBOX
28
return
FX_ArrayBufferAllocate(length);
29
#
endif
// V8_ENABLE_SANDBOX
30
}
31
32
void
* CFX_V8ArrayBufferAllocator::
AllocateUninitialized
(size_t length) {
33
if
(length > kMaxAllowedBytes)
34
return
nullptr
;
35
#
ifdef
V8_ENABLE_SANDBOX
36
if
(!wrapped_) {
37
wrapped_.reset(v8::ArrayBuffer::Allocator::NewDefaultAllocator());
38
}
39
return
wrapped_->AllocateUninitialized(length);
40
#
else
// V8_ENABLE_SANDBOX
41
return
FX_ArrayBufferAllocateUninitialized(length);
42
#
endif
43
}
44
45
void
CFX_V8ArrayBufferAllocator::
Free
(
void
* data, size_t length) {
46
#
ifdef
V8_ENABLE_SANDBOX
47
if
(wrapped_) {
48
wrapped_->Free(data, length);
49
}
50
#
else
// V8_ENABLE_SANDBOX
51
FX_ArrayBufferFree
(
data
)
;
52
#
endif
53
}
CFX_V8ArrayBufferAllocator::Free
void Free(void *data, size_t length) override
Definition
cfx_v8_array_buffer_allocator.cpp:45
CFX_V8ArrayBufferAllocator::AllocateUninitialized
void * AllocateUninitialized(size_t length) override
Definition
cfx_v8_array_buffer_allocator.cpp:32
CFX_V8ArrayBufferAllocator::Allocate
void * Allocate(size_t length) override
Definition
cfx_v8_array_buffer_allocator.cpp:19
CFX_V8ArrayBufferAllocator::CFX_V8ArrayBufferAllocator
CFX_V8ArrayBufferAllocator()
CFX_V8ArrayBufferAllocator::~CFX_V8ArrayBufferAllocator
~CFX_V8ArrayBufferAllocator() override
FX_ArrayBufferFree
void FX_ArrayBufferFree(void *data)
Definition
fx_memory_malloc.cpp:87
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxjs
cfx_v8_array_buffer_allocator.cpp
Generated on
for Qt by
1.18.0