Closed Bug 1271488 Opened 4 years ago Closed 4 years ago

implement JS_NewArrayBufferWithExternalContents

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: tbsaunde, Unassigned)

Details

(Whiteboard: [v8api])

Attachments

(1 file)

v8 has array buffers where the data can out live the buffer pointing to them, and the embedder owns the data.
JS_NewArrayBufferWithExternalContents() is basically the same as
JS_NewArrayBufferWithContents() accept the js engine won't free the data when
the buffer goes away or is detached.
Attachment #8750928 - Flags: review?(sphink)
Comment on attachment 8750928 [details] [diff] [review]
allow an embedder to retain ownership of an array buffer's contents

Review of attachment 8750928 [details] [diff] [review]:
-----------------------------------------------------------------

Sorry, I didn't notice you already had this ready.

Looks just right to me.

I kinda wish we had a C++ API instead of these mile-long names, but that's for later.

::: js/src/jsapi-tests/testExternalArrayBuffer.cpp
@@ +16,5 @@
> +}
> +
> +BEGIN_TEST(testExternalArrayBuffer)
> +{
> +  size_t length = sizeof(test_data);

half-indent

::: js/src/jsapi.h
@@ +3510,5 @@
>  JS_NewArrayBufferWithContents(JSContext* cx, size_t nbytes, void* contents);
>  
>  /**
> + * Create a new array buffer with the given contents.  The array buffer does not take ownership of
> + * contents, and JS_DetachArrayBuffer must be called befor the contents are disposed of.

*before
Attachment #8750928 - Flags: review?(sphink) → review+
https://hg.mozilla.org/mozilla-central/rev/052cbe57e190
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in before you can comment on or make changes to this bug.