29
29
#[ allow( missing_doc) ] ;
30
30
31
31
use c_str:: ToCStr ;
32
- use cast;
33
32
use clone:: Clone ;
34
33
use container:: Container ;
35
34
use io;
@@ -246,10 +245,10 @@ pub fn getenv(n: &str) -> Option<~str> {
246
245
let s = do n. to_c_str ( ) . with_ref |buf| {
247
246
libc:: getenv ( buf)
248
247
} ;
249
- if ptr :: null :: < u8 > ( ) == cast :: transmute ( s ) {
248
+ if s . is_null ( ) {
250
249
None
251
250
} else {
252
- Some ( str:: raw:: from_buf ( cast :: transmute ( s ) ) )
251
+ Some ( str:: raw:: from_c_str ( s ) )
253
252
}
254
253
}
255
254
}
@@ -643,8 +642,7 @@ pub fn make_dir(p: &Path, mode: c_int) -> bool {
643
642
use os:: win32:: as_utf16_p;
644
643
// FIXME: turn mode into something useful? #2623
645
644
do as_utf16_p( p. to_str ( ) ) |buf| {
646
- libc:: CreateDirectoryW ( buf, cast:: transmute ( 0 ) )
647
- != ( 0 as libc:: BOOL )
645
+ libc:: CreateDirectoryW ( buf, ptr:: null ( ) ) != ( 0 as libc:: BOOL )
648
646
}
649
647
}
650
648
}
@@ -748,10 +746,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
748
746
do as_utf16_p( star ( p) . to_str ( ) ) |path_ptr| {
749
747
let mut strings = ~[ ] ;
750
748
let wfd_ptr = malloc_raw ( rust_list_dir_wfd_size ( ) as uint ) ;
751
- let find_handle =
752
- FindFirstFileW (
753
- path_ptr,
754
- :: cast:: transmute ( wfd_ptr) ) ;
749
+ let find_handle = FindFirstFileW ( path_ptr, wfd_ptr as HANDLE ) ;
755
750
if find_handle as libc:: c_int != INVALID_HANDLE_VALUE {
756
751
let mut more_files = 1 as libc:: c_int ;
757
752
while more_files != 0 {
@@ -765,9 +760,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
765
760
let fp_str = str:: from_utf16 ( fp_vec) ;
766
761
strings. push ( fp_str) ;
767
762
}
768
- more_files = FindNextFileW (
769
- find_handle,
770
- :: cast:: transmute ( wfd_ptr) ) ;
763
+ more_files = FindNextFileW ( find_handle, wfd_ptr as HANDLE ) ;
771
764
}
772
765
FindClose ( find_handle) ;
773
766
free ( wfd_ptr)
@@ -1195,7 +1188,7 @@ pub fn real_args() -> ~[~str] {
1195
1188
}
1196
1189
1197
1190
unsafe {
1198
- LocalFree ( cast :: transmute ( szArgList) ) ;
1191
+ LocalFree ( szArgList as * c_void ) ;
1199
1192
}
1200
1193
1201
1194
return args;
0 commit comments