File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -52,10 +52,9 @@ impl DoubleEndedIterator for Args {
5252mod imp {
5353 use os:: unix:: prelude:: * ;
5454 use mem;
55- use ffi:: OsString ;
55+ use ffi:: { CStr , OsString } ;
5656 use marker:: PhantomData ;
57- use slice;
58- use str;
57+ use libc;
5958 use super :: Args ;
6059
6160 use sys_common:: mutex:: Mutex ;
@@ -64,12 +63,9 @@ mod imp {
6463 static LOCK : Mutex = Mutex :: new ( ) ;
6564
6665 pub unsafe fn init ( argc : isize , argv : * const * const u8 ) {
67- let mut args: Vec < Vec < u8 > > = Vec :: new ( ) ;
68- for i in 0 ..argc {
69- let len = * ( argv. offset ( i * 2 ) ) as usize ;
70- let ptr = * ( argv. offset ( i * 2 + 1 ) ) ;
71- args. push ( slice:: from_raw_parts ( ptr, len) . to_vec ( ) ) ;
72- }
66+ let args = ( 0 ..argc) . map ( |i| {
67+ CStr :: from_ptr ( * argv. offset ( i) as * const libc:: c_char ) . to_bytes ( ) . to_vec ( )
68+ } ) . collect ( ) ;
7369
7470 LOCK . lock ( ) ;
7571 let ptr = get_global_ptr ( ) ;
You can’t perform that action at this time.
0 commit comments