native: be more const correct with the FFI calls.
These calls are mutating their argument and so it's bad behaviour to be pretending that the values are immutable to rustc.
This commit is contained in:
parent
8b246fda78
commit
4cc723dc22
@ -14,7 +14,7 @@ use std::cast;
|
||||
use std::io::IoError;
|
||||
use std::libc;
|
||||
use std::libc::{c_char, c_int};
|
||||
use std::ptr::null;
|
||||
use std::ptr::{null, mut_null};
|
||||
|
||||
use super::net::sockaddr_to_addr;
|
||||
|
||||
@ -42,13 +42,13 @@ impl GetAddrInfoRequest {
|
||||
});
|
||||
|
||||
let hint_ptr = hint.as_ref().map_or(null(), |x| x as *libc::addrinfo);
|
||||
let res = null();
|
||||
let mut res = mut_null();
|
||||
|
||||
// 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) };
|
||||
getaddrinfo(ch, cs, hint_ptr, &res)
|
||||
getaddrinfo(ch, cs, hint_ptr, &mut res)
|
||||
};
|
||||
|
||||
// Error?
|
||||
@ -74,7 +74,7 @@ impl GetAddrInfoRequest {
|
||||
flags: (*rp).ai_flags as uint
|
||||
});
|
||||
|
||||
rp = (*rp).ai_next;
|
||||
rp = (*rp).ai_next as *mut libc::addrinfo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,8 +86,8 @@ impl GetAddrInfoRequest {
|
||||
|
||||
extern "system" {
|
||||
fn getaddrinfo(node: *c_char, service: *c_char,
|
||||
hints: *libc::addrinfo, res: **libc::addrinfo) -> c_int;
|
||||
fn freeaddrinfo(res: *libc::addrinfo);
|
||||
hints: *libc::addrinfo, res: *mut *mut libc::addrinfo) -> c_int;
|
||||
fn freeaddrinfo(res: *mut libc::addrinfo);
|
||||
#[cfg(not(windows))]
|
||||
fn gai_strerror(errcode: c_int) -> *c_char;
|
||||
#[cfg(windows)]
|
||||
|
@ -91,7 +91,7 @@ impl FileDesc {
|
||||
#[cfg(not(windows))] type rlen = libc::size_t;
|
||||
let ret = retry(|| unsafe {
|
||||
libc::read(self.fd(),
|
||||
buf.as_ptr() as *mut libc::c_void,
|
||||
buf.as_mut_ptr() as *mut libc::c_void,
|
||||
buf.len() as rlen) as libc::c_int
|
||||
});
|
||||
if ret == 0 {
|
||||
|
@ -309,7 +309,7 @@ impl rtio::RtioTcpStream for TcpStream {
|
||||
let ret = retry(|| {
|
||||
unsafe {
|
||||
libc::recv(self.fd(),
|
||||
buf.as_ptr() as *mut libc::c_void,
|
||||
buf.as_mut_ptr() as *mut libc::c_void,
|
||||
buf.len() as wrlen,
|
||||
0) as libc::c_int
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user