about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-06-14 22:50:07 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2014-06-29 21:15:26 +1000
commitd4d4bc4fe944c1b0627d104127352046879f9dc0 (patch)
tree1df80b73fef91c4e7327e502f64cb902c93d9a70 /src/libnative
parent2c9aada10cd9146138d76d182ccbd2a7627df204 (diff)
downloadrust-d4d4bc4fe944c1b0627d104127352046879f9dc0.tar.gz
rust-d4d4bc4fe944c1b0627d104127352046879f9dc0.zip
c_str: replace .with_ref with .as_ptr throughout the codebase.
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/io/addrinfo.rs4
-rw-r--r--src/libnative/io/file_unix.rs30
-rw-r--r--src/libnative/io/file_win32.rs4
-rw-r--r--src/libnative/io/pipe_unix.rs2
-rw-r--r--src/libnative/io/process.rs8
5 files changed, 24 insertions, 24 deletions
diff --git a/src/libnative/io/addrinfo.rs b/src/libnative/io/addrinfo.rs
index 8c3cdf4e9ec..0977b55d8b9 100644
--- a/src/libnative/io/addrinfo.rs
+++ b/src/libnative/io/addrinfo.rs
@@ -50,8 +50,8 @@ impl GetAddrInfoRequest {
 
         // Make the call
         let s = unsafe {
-            let ch = if c_host.is_null() { null() } else { c_host.with_ref(|x| x) };
-            let cs = if c_serv.is_null() { null() } else { c_serv.with_ref(|x| x) };
+            let ch = if c_host.is_null() { null() } else { c_host.as_ptr() };
+            let cs = if c_serv.is_null() { null() } else { c_serv.as_ptr() };
             getaddrinfo(ch, cs, hint_ptr, &mut res)
         };
 
diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs
index 72dad27c6e7..ddcff2be5f3 100644
--- a/src/libnative/io/file_unix.rs
+++ b/src/libnative/io/file_unix.rs
@@ -339,7 +339,7 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
                             libc::S_IRUSR | libc::S_IWUSR),
     };
 
-    match retry(|| unsafe { libc::open(path.with_ref(|p| p), flags, mode) }) {
+    match retry(|| unsafe { libc::open(path.as_ptr(), flags, mode) }) {
         -1 => Err(super::last_error()),
         fd => Ok(FileDesc::new(fd, true)),
     }
@@ -347,7 +347,7 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
 
 pub fn mkdir(p: &CString, mode: uint) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::mkdir(p.with_ref(|p| p), mode as libc::mode_t)
+        libc::mkdir(p.as_ptr(), mode as libc::mode_t)
     }))
 }
 
@@ -356,7 +356,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
     use libc::{opendir, readdir_r, closedir};
 
     fn prune(root: &CString, dirs: Vec<Path>) -> Vec<CString> {
-        let root = unsafe { CString::new(root.with_ref(|p| p), false) };
+        let root = unsafe { CString::new(root.as_ptr(), false) };
         let root = Path::new(root);
 
         dirs.move_iter().filter(|path| {
@@ -373,7 +373,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
     let mut buf = Vec::<u8>::with_capacity(size as uint);
     let ptr = buf.as_mut_slice().as_mut_ptr() as *mut dirent_t;
 
-    let dir_ptr = p.with_ref(|buf| unsafe { opendir(buf) });
+    let dir_ptr = unsafe {opendir(p.as_ptr())};
 
     if dir_ptr as uint != 0 {
         let mut paths = vec!();
@@ -393,36 +393,36 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
 }
 
 pub fn unlink(p: &CString) -> IoResult<()> {
-    super::mkerr_libc(retry(|| unsafe { libc::unlink(p.with_ref(|p| p)) }))
+    super::mkerr_libc(retry(|| unsafe { libc::unlink(p.as_ptr()) }))
 }
 
 pub fn rename(old: &CString, new: &CString) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::rename(old.with_ref(|p| p), new.with_ref(|p| p))
+        libc::rename(old.as_ptr(), new.as_ptr())
     }))
 }
 
 pub fn chmod(p: &CString, mode: uint) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::chmod(p.with_ref(|p| p), mode as libc::mode_t)
+        libc::chmod(p.as_ptr(), mode as libc::mode_t)
     }))
 }
 
 pub fn rmdir(p: &CString) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::rmdir(p.with_ref(|p| p))
+        libc::rmdir(p.as_ptr())
     }))
 }
 
 pub fn chown(p: &CString, uid: int, gid: int) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::chown(p.with_ref(|p| p), uid as libc::uid_t,
+        libc::chown(p.as_ptr(), uid as libc::uid_t,
                     gid as libc::gid_t)
     }))
 }
 
 pub fn readlink(p: &CString) -> IoResult<CString> {
-    let p = p.with_ref(|p| p);
+    let p = p.as_ptr();
     let mut len = unsafe { libc::pathconf(p as *mut _, libc::_PC_NAME_MAX) };
     if len == -1 {
         len = 1024; // FIXME: read PATH_MAX from C ffi?
@@ -443,13 +443,13 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
 
 pub fn symlink(src: &CString, dst: &CString) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::symlink(src.with_ref(|p| p), dst.with_ref(|p| p))
+        libc::symlink(src.as_ptr(), dst.as_ptr())
     }))
 }
 
 pub fn link(src: &CString, dst: &CString) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::link(src.with_ref(|p| p), dst.with_ref(|p| p))
+        libc::link(src.as_ptr(), dst.as_ptr())
     }))
 }
 
@@ -489,7 +489,7 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat {
 
 pub fn stat(p: &CString) -> IoResult<rtio::FileStat> {
     let mut stat: libc::stat = unsafe { mem::zeroed() };
-    match retry(|| unsafe { libc::stat(p.with_ref(|p| p), &mut stat) }) {
+    match retry(|| unsafe { libc::stat(p.as_ptr(), &mut stat) }) {
         0 => Ok(mkstat(&stat)),
         _ => Err(super::last_error()),
     }
@@ -497,7 +497,7 @@ pub fn stat(p: &CString) -> IoResult<rtio::FileStat> {
 
 pub fn lstat(p: &CString) -> IoResult<rtio::FileStat> {
     let mut stat: libc::stat = unsafe { mem::zeroed() };
-    match retry(|| unsafe { libc::lstat(p.with_ref(|p| p), &mut stat) }) {
+    match retry(|| unsafe { libc::lstat(p.as_ptr(), &mut stat) }) {
         0 => Ok(mkstat(&stat)),
         _ => Err(super::last_error()),
     }
@@ -509,7 +509,7 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
         modtime: (mtime / 1000) as libc::time_t,
     };
     super::mkerr_libc(retry(|| unsafe {
-        libc::utime(p.with_ref(|p| p), &buf)
+        libc::utime(p.as_ptr(), &buf)
     }))
 }
 
diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs
index cdbf762f87d..3195fa4f2d4 100644
--- a/src/libnative/io/file_win32.rs
+++ b/src/libnative/io/file_win32.rs
@@ -347,7 +347,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
     use std::rt::libc_heap::malloc_raw;
 
     fn prune(root: &CString, dirs: Vec<Path>) -> Vec<CString> {
-        let root = unsafe { CString::new(root.with_ref(|p| p), false) };
+        let root = unsafe { CString::new(root.as_ptr(), false) };
         let root = Path::new(root);
 
         dirs.move_iter().filter(|path| {
@@ -360,7 +360,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
         fn rust_list_dir_wfd_fp_buf(wfd: *mut libc::c_void) -> *const u16;
     }
     let star = Path::new(unsafe {
-        CString::new(p.with_ref(|p| p), false)
+        CString::new(p.as_ptr(), false)
     }).join("*");
     let path = try!(to_utf16(&star.to_c_str()));
 
diff --git a/src/libnative/io/pipe_unix.rs b/src/libnative/io/pipe_unix.rs
index ae08d0ea0a9..b5b2065f996 100644
--- a/src/libnative/io/pipe_unix.rs
+++ b/src/libnative/io/pipe_unix.rs
@@ -278,7 +278,7 @@ impl Drop for UnixListener {
         // careful to unlink the path before we close the file descriptor to
         // prevent races where we unlink someone else's path.
         unsafe {
-            let _ = libc::unlink(self.path.with_ref(|p| p));
+            let _ = libc::unlink(self.path.as_ptr());
         }
     }
 }
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs
index 7f4c52585f2..00448b91dbd 100644
--- a/src/libnative/io/process.rs
+++ b/src/libnative/io/process.rs
@@ -531,7 +531,7 @@ fn spawn_process_os(cfg: ProcessConfig,
         assert_eq!(ret, 0);
     }
 
-    let dirp = cfg.cwd.map(|c| c.with_ref(|p| p)).unwrap_or(ptr::null());
+    let dirp = cfg.cwd.map(|c| c.as_ptr()).unwrap_or(ptr::null());
 
     let cfg = unsafe {
         mem::transmute::<ProcessConfig,ProcessConfig<'static>>(cfg)
@@ -633,7 +633,7 @@ fn spawn_process_os(cfg: ProcessConfig,
                         } else {
                             libc::O_RDWR
                         };
-                        devnull.with_ref(|p| libc::open(p, flags, 0))
+                        libc::open(devnull.as_ptr(), flags, 0)
                     }
                     Some(obj) => {
                         let fd = obj.fd();
@@ -715,8 +715,8 @@ fn with_argv<T>(prog: &CString, args: &[CString],
     // larger than the lifetime of our invocation of cb, but this is
     // technically unsafe as the callback could leak these pointers
     // out of our scope.
-    ptrs.push(prog.with_ref(|buf| buf));
-    ptrs.extend(args.iter().map(|tmp| tmp.with_ref(|buf| buf)));
+    ptrs.push(prog.as_ptr());
+    ptrs.extend(args.iter().map(|tmp| tmp.as_ptr()));
 
     // Add a terminating null pointer (required by libc).
     ptrs.push(ptr::null());