Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-11-13 22:22:46 +0300
committerMyles Borins <mylesborins@google.com>2019-11-21 08:29:27 +0300
commit21dd6019ecb8134e2b6af74ccc557cab8bc75413 (patch)
treec292323e66da6adf961e127560fafc7f95dadcac /src/node_buffer.h
parent2e43686c5a21701a3a85171906e010aadefeb1ad (diff)
src: expose ArrayBuffer version of Buffer::New()
This can be useful to create `Buffer` instances for already-existing `ArrayBuffer`s, e.g. ones created manually from a backing store with a free callback (of which our variant in the public API has some limitations). PR-URL: https://github.com/nodejs/node/pull/30476 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_buffer.h')
-rw-r--r--src/node_buffer.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node_buffer.h b/src/node_buffer.h
index 122afc37709..11010017ce0 100644
--- a/src/node_buffer.h
+++ b/src/node_buffer.h
@@ -65,6 +65,12 @@ NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
char* data,
size_t len);
+// Creates a Buffer instance over an existing ArrayBuffer.
+NODE_EXTERN v8::MaybeLocal<v8::Uint8Array> New(v8::Isolate* isolate,
+ v8::Local<v8::ArrayBuffer> ab,
+ size_t byte_offset,
+ size_t length);
+
// This is verbose to be explicit with inline commenting
static inline bool IsWithinBounds(size_t off, size_t len, size_t max) {
// Asking to seek too far into the buffer