nodejs/deps/v8/test/cctest/manually-externalized-buffer.h
Matheus Marchini 2883c855e0
deps: update V8 to 8.1.307.20
PR-URL: https://github.com/nodejs/node/pull/32116
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-03-18 16:23:22 -07:00

35 lines
1.0 KiB
C++

// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_CCTEST_MANUALLY_EXTERNALIZED_BUFFER_H_
#define V8_CCTEST_MANUALLY_EXTERNALIZED_BUFFER_H_
#include "src/api/api-inl.h"
namespace v8 {
namespace internal {
namespace testing {
// Utility to free the allocated memory for a buffer that is manually
// externalized in a test.
struct ManuallyExternalizedBuffer {
Handle<JSArrayBuffer> buffer_;
std::shared_ptr<v8::BackingStore> backing_store_;
explicit ManuallyExternalizedBuffer(Handle<JSArrayBuffer> buffer)
: buffer_(buffer),
backing_store_(v8::Utils::ToLocal(buffer_)->GetBackingStore()) {}
~ManuallyExternalizedBuffer() {
// Nothing to be done. The reference to the backing store will be
// dropped automatically.
}
void* backing_store() { return backing_store_->Data(); }
};
} // namespace testing
} // namespace internal
} // namespace v8
#endif // V8_CCTEST_MANUALLY_EXTERNALIZED_BUFFER_H_