mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-25 00:29:14 -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
|
/// 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.
|
/// 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]>,
|
data: Box<[u8]>,
|
||||||
) -> UniqueRef<BackingStore> {
|
) -> UniqueRef<BackingStore> {
|
||||||
let byte_length = data.len();
|
let byte_length = data.len();
|
||||||
let data_ptr = Box::into_raw(data) as *mut c_void;
|
let data_ptr = Box::into_raw(data) as *mut c_void;
|
||||||
|
unsafe {
|
||||||
UniqueRef::from_raw(v8__SharedArrayBuffer__NewBackingStore__with_data(
|
UniqueRef::from_raw(v8__SharedArrayBuffer__NewBackingStore__with_data(
|
||||||
data_ptr,
|
data_ptr,
|
||||||
byte_length,
|
byte_length,
|
||||||
|
@ -125,4 +126,5 @@ impl SharedArrayBuffer {
|
||||||
null_mut(),
|
null_mut(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 data: Box<[u8]> = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9].into_boxed_slice();
|
||||||
let bs = unsafe {
|
let bs = v8::SharedArrayBuffer::new_backing_store_from_boxed_slice(data);
|
||||||
v8::SharedArrayBuffer::new_backing_store_from_boxed_slice(data)
|
|
||||||
};
|
|
||||||
assert_eq!(bs.byte_length(), 10);
|
assert_eq!(bs.byte_length(), 10);
|
||||||
assert_eq!(bs.is_shared(), true);
|
assert_eq!(bs.is_shared(), true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue