0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-24 00:00:06 -05:00

SharedArrayBuffer::new_backing_store_from_boxed_slice doesn't need to be unsafe

This commit is contained in:
Ryan Dahl 2020-01-23 12:16:56 -05:00
parent 96309e9679
commit 093e09217c
2 changed files with 10 additions and 10 deletions

View file

@ -113,16 +113,18 @@ 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;
UniqueRef::from_raw(v8__SharedArrayBuffer__NewBackingStore__with_data(
data_ptr,
byte_length,
backing_store_deleter_callback,
null_mut(),
))
unsafe {
UniqueRef::from_raw(v8__SharedArrayBuffer__NewBackingStore__with_data(
data_ptr,
byte_length,
backing_store_deleter_callback,
null_mut(),
))
}
}
}

View file

@ -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);