Skip to content

Commit 88df0e3

Browse files
committed
Fix arguments on Redox
1 parent 86896ba commit 88df0e3

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/libstd/sys/redox/args.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ impl DoubleEndedIterator for Args {
5252
mod 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();

0 commit comments

Comments
 (0)