mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-24 08:09:16 -05:00
SharedArrayBuffer::new_backing_store_from_boxed_slice doesn't need to be unsafe
This commit is contained in:
parent
96309e9679
commit
093e09217c
2 changed files with 10 additions and 10 deletions
|
@ -113,11 +113,12 @@ impl SharedArrayBuffer {
|
|||
///
|
||||
/// The result can be later passed to SharedArrayBuffer::New. The raw pointer
|
||||
/// to the buffer must not be passed again to any V8 API function.
|
||||
pub unsafe fn new_backing_store_from_boxed_slice(
|
||||
pub fn new_backing_store_from_boxed_slice(
|
||||
data: Box<[u8]>,
|
||||
) -> UniqueRef<BackingStore> {
|
||||
let byte_length = data.len();
|
||||
let data_ptr = Box::into_raw(data) as *mut c_void;
|
||||
unsafe {
|
||||
UniqueRef::from_raw(v8__SharedArrayBuffer__NewBackingStore__with_data(
|
||||
data_ptr,
|
||||
byte_length,
|
||||
|
@ -126,3 +127,4 @@ impl SharedArrayBuffer {
|
|||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1913,9 +1913,7 @@ fn shared_array_buffer() {
|
|||
}
|
||||
|
||||
let data: Box<[u8]> = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9].into_boxed_slice();
|
||||
let bs = unsafe {
|
||||
v8::SharedArrayBuffer::new_backing_store_from_boxed_slice(data)
|
||||
};
|
||||
let bs = v8::SharedArrayBuffer::new_backing_store_from_boxed_slice(data);
|
||||
assert_eq!(bs.byte_length(), 10);
|
||||
assert_eq!(bs.is_shared(), true);
|
||||
|
||||
|
|
Loading…
Reference in a new issue