mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Remove some unnecessary transmutes.
These can either be done by implicit `&` -> `*` coercions, explicit `*` -> `*` casts, or an explicit `&*x` `*` -> `&` re-borrow (which is still unsafe, but significantly more controlled compared to a `transmute`).
This commit is contained in:
parent
3401a568f2
commit
94e4ab3eaf
5 changed files with 14 additions and 19 deletions
|
@ -74,7 +74,7 @@ pub fn _obj_toString(cx: *JSContext, className: *libc::c_char) -> *JSString {
|
|||
unsafe {
|
||||
let name = str::raw::from_c_str(className);
|
||||
let nchars = "[object ]".len() + name.len();
|
||||
let chars: *mut jschar = cast::transmute(JS_malloc(cx, (nchars + 1) as libc::size_t * (size_of::<jschar>() as libc::size_t)));
|
||||
let chars: *mut jschar = JS_malloc(cx, (nchars + 1) as libc::size_t * (size_of::<jschar>() as libc::size_t)) as *mut jschar;
|
||||
if chars.is_null() {
|
||||
return ptr::null();
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ pub fn _obj_toString(cx: *JSContext, className: *libc::c_char) -> *JSString {
|
|||
*chars.offset(i as int) = c as jschar;
|
||||
}
|
||||
*chars.offset(nchars as int) = 0;
|
||||
let jsstr = JS_NewUCString(cx, cast::transmute(chars), nchars as libc::size_t);
|
||||
let jsstr = JS_NewUCString(cx, chars as *jschar, nchars as libc::size_t);
|
||||
if jsstr.is_null() {
|
||||
JS_free(cx, cast::transmute(chars));
|
||||
JS_free(cx, chars as *libc::c_void);
|
||||
}
|
||||
jsstr
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue