blob: 4c0eb2d0cf68f1bb6a11f743629098bc84b76302 [file] [log] [blame]
Lei Zhang020fbf22021-09-21 21:58:22 +00001// Copyright 2021 PDFium Authors. All rights reserved.
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"
Lei Zhang020fbf22021-09-21 21:58:22 +000010
11void* CFX_V8ArrayBufferAllocator::Allocate(size_t length) {
12 if (length > kMaxAllowedBytes)
13 return nullptr;
Tom Sepez83e6ac32022-08-15 21:24:58 +000014 return FX_ArrayBufferAllocate(length);
Lei Zhang020fbf22021-09-21 21:58:22 +000015}
16
17void* CFX_V8ArrayBufferAllocator::AllocateUninitialized(size_t length) {
18 if (length > kMaxAllowedBytes)
19 return nullptr;
Tom Sepez83e6ac32022-08-15 21:24:58 +000020 return FX_ArrayBufferAllocateUninitialized(length);
Lei Zhang020fbf22021-09-21 21:58:22 +000021}
22
23void CFX_V8ArrayBufferAllocator::Free(void* data, size_t length) {
Tom Sepez83e6ac32022-08-15 21:24:58 +000024 FX_ArrayBufferFree(data);
Lei Zhang020fbf22021-09-21 21:58:22 +000025}