Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Option<T> to return from getters #13100

Merged
merged 6 commits into from Aug 31, 2016

Root js_object in TextEncoder::Encode

  • Loading branch information
nox committed Aug 30, 2016
commit 3e32948a39ced28c12f38ce115abcb56e67e72d9
@@ -74,12 +74,13 @@ impl TextEncoderMethods for TextEncoder {
unsafe {
let encoded = self.encoder.encode(&input.0, EncoderTrap::Strict).unwrap();
let length = encoded.len() as u32;
let js_object: *mut JSObject = JS_NewUint8Array(cx, length);
rooted!(in(cx) let js_object = JS_NewUint8Array(cx, length));
assert!(!js_object.is_null());
let mut is_shared = false;
let js_object_data: *mut uint8_t = JS_GetUint8ArrayData(js_object, &mut is_shared, ptr::null());
let js_object_data: *mut uint8_t = JS_GetUint8ArrayData(js_object.get(), &mut is_shared, ptr::null());
assert!(!is_shared);
ptr::copy_nonoverlapping(encoded.as_ptr(), js_object_data, length as usize);
js_object
js_object.get()
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.