diff --git a/doc/guide-ffi.md b/doc/guide-ffi.md index 236da56588e9..217eab527582 100644 --- a/doc/guide-ffi.md +++ b/doc/guide-ffi.md @@ -230,7 +230,7 @@ impl Drop for Unique { // We need to move the object out of the box, so that // the destructor is called (at the end of this scope.) ptr::replace_ptr(self.ptr, x); - free(self.ptr as *c_void) + free(self.ptr as *mut c_void) } } } diff --git a/src/libextra/c_vec.rs b/src/libextra/c_vec.rs index fc2caa13584d..35a6ccaa7083 100644 --- a/src/libextra/c_vec.rs +++ b/src/libextra/c_vec.rs @@ -172,7 +172,7 @@ mod tests { let mem = malloc_raw(n); CVec::new_with_dtor(mem as *mut u8, n, - proc() { libc::free(mem as *c_void); }) + proc() { libc::free(mem as *mut c_void); }) } } diff --git a/src/libextra/flate.rs b/src/libextra/flate.rs index 1153c3a6ef30..faceb17af476 100644 --- a/src/libextra/flate.rs +++ b/src/libextra/flate.rs @@ -53,7 +53,7 @@ fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> ~[u8] { assert!(res as int != 0); let out = vec::raw::from_buf_raw(res as *u8, outsz as uint); - libc::free(res); + libc::free(res as *mut c_void); out } } @@ -76,7 +76,7 @@ fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> ~[u8] { assert!(res as int != 0); let out = vec::raw::from_buf_raw(res as *u8, outsz as uint); - libc::free(res); + libc::free(res as *mut c_void); out } } diff --git a/src/libnative/io/file.rs b/src/libnative/io/file.rs index af6ed51729ef..af06533d44bd 100644 --- a/src/libnative/io/file.rs +++ b/src/libnative/io/file.rs @@ -548,13 +548,13 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> { let p = Path::new(p); let star = p.join("*"); as_utf16_p(star.as_str().unwrap(), |path_ptr| { - let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint) as *c_void; + let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint); let find_handle = FindFirstFileW(path_ptr, wfd_ptr as HANDLE); if find_handle as libc::c_int != INVALID_HANDLE_VALUE { let mut paths = ~[]; let mut more_files = 1 as libc::c_int; while more_files != 0 { - let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr); + let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr as *c_void); if fp_buf as uint == 0 { fail!("os::list_dir() failure: got null ptr from wfd"); } @@ -567,7 +567,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> { more_files = FindNextFileW(find_handle, wfd_ptr as HANDLE); } FindClose(find_handle); - free(wfd_ptr); + free(wfd_ptr as *mut c_void); Ok(paths) } else { Err(super::last_error()) diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index c259fa6a6183..3693b00951bc 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -1836,7 +1836,7 @@ impl TypeNames { unsafe { let s = llvm::LLVMTypeToString(ty.to_ref()); let ret = from_c_str(s); - free(s as *c_void); + free(s as *mut c_void); ret } } @@ -1850,7 +1850,7 @@ impl TypeNames { unsafe { let s = llvm::LLVMValueToString(val); let ret = from_c_str(s); - free(s as *c_void); + free(s as *mut c_void); ret } } diff --git a/src/librustuv/uvll.rs b/src/librustuv/uvll.rs index 189a820cd3ee..0a6e23e99564 100644 --- a/src/librustuv/uvll.rs +++ b/src/librustuv/uvll.rs @@ -373,7 +373,7 @@ pub unsafe fn malloc_handle(handle: uv_handle_type) -> *c_void { } pub unsafe fn free_handle(v: *c_void) { - free(v) + free(v as *mut c_void) } pub unsafe fn malloc_req(req: uv_req_type) -> *c_void { @@ -383,7 +383,7 @@ pub unsafe fn malloc_req(req: uv_req_type) -> *c_void { } pub unsafe fn free_req(v: *c_void) { - free(v) + free(v as *mut c_void) } #[test] diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index c735e3250682..22e93e581944 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -183,7 +183,7 @@ impl Drop for CString { fn drop(&mut self) { if self.owns_buffer_ { unsafe { - libc::free(self.buf as *libc::c_void) + libc::free(self.buf as *mut libc::c_void) } } } @@ -459,7 +459,7 @@ mod tests { #[test] fn test_unwrap() { let c_str = "hello".to_c_str(); - unsafe { libc::free(c_str.unwrap() as *libc::c_void) } + unsafe { libc::free(c_str.unwrap() as *mut libc::c_void) } } #[test] diff --git a/src/libstd/libc.rs b/src/libstd/libc.rs index 77ac226a7f16..a2aa182216a6 100644 --- a/src/libstd/libc.rs +++ b/src/libstd/libc.rs @@ -3225,7 +3225,7 @@ pub mod funcs { pub fn calloc(nobj: size_t, size: size_t) -> *c_void; pub fn malloc(size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; - pub fn free(p: *c_void); + pub fn free(p: *mut c_void); pub fn exit(status: c_int) -> !; // Omitted: atexit. pub fn system(s: *c_char) -> c_int; diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index 54442cedb683..ead78ce41ef9 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -52,7 +52,7 @@ pub unsafe fn realloc_raw(ptr: *mut u8, size: uint) -> *mut u8 { // `realloc(ptr, 0)` may allocate, but it may also return a null pointer // http://pubs.opengroup.org/onlinepubs/9699919799/functions/realloc.html if size == 0 { - free(ptr as *c_void); + free(ptr); mut_null() } else { let p = realloc(ptr as *mut c_void, size as size_t); @@ -107,7 +107,7 @@ pub unsafe fn exchange_free_(ptr: *u8) { #[inline] pub unsafe fn exchange_free(ptr: *u8) { - free(ptr as *c_void); + free(ptr as *mut c_void); } #[cfg(test)] diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs index e99e9ef09403..e740862fddfb 100644 --- a/src/libstd/sync/deque.rs +++ b/src/libstd/sync/deque.rs @@ -389,7 +389,7 @@ impl Buffer { impl Drop for Buffer { fn drop(&mut self) { // It is assumed that all buffers are empty on drop. - unsafe { libc::free(self.storage as *libc::c_void) } + unsafe { libc::free(self.storage as *mut libc::c_void) } } } diff --git a/src/libstd/unstable/mutex.rs b/src/libstd/unstable/mutex.rs index ff38a8c01993..69c6204cc323 100644 --- a/src/libstd/unstable/mutex.rs +++ b/src/libstd/unstable/mutex.rs @@ -173,49 +173,49 @@ mod imp { type pthread_condattr_t = libc::c_void; pub unsafe fn init_lock() -> uint { - let block = malloc_raw(rust_pthread_mutex_t_size() as uint) as *pthread_mutex_t; + let block = malloc_raw(rust_pthread_mutex_t_size() as uint) as *mut pthread_mutex_t; let n = pthread_mutex_init(block, ptr::null()); assert_eq!(n, 0); return block as uint; } pub unsafe fn init_cond() -> uint { - let block = malloc_raw(rust_pthread_cond_t_size() as uint) as *pthread_cond_t; + let block = malloc_raw(rust_pthread_cond_t_size() as uint) as *mut pthread_cond_t; let n = pthread_cond_init(block, ptr::null()); assert_eq!(n, 0); return block as uint; } pub unsafe fn free_lock(h: uint) { - let block = h as *libc::c_void; + let block = h as *mut libc::c_void; assert_eq!(pthread_mutex_destroy(block), 0); libc::free(block); } pub unsafe fn free_cond(h: uint) { - let block = h as *pthread_cond_t; + let block = h as *mut pthread_cond_t; assert_eq!(pthread_cond_destroy(block), 0); libc::free(block); } pub unsafe fn lock(l: uint) { - assert_eq!(pthread_mutex_lock(l as *pthread_mutex_t), 0); + assert_eq!(pthread_mutex_lock(l as *mut pthread_mutex_t), 0); } pub unsafe fn trylock(l: uint) -> bool { - pthread_mutex_trylock(l as *pthread_mutex_t) == 0 + pthread_mutex_trylock(l as *mut pthread_mutex_t) == 0 } pub unsafe fn unlock(l: uint) { - assert_eq!(pthread_mutex_unlock(l as *pthread_mutex_t), 0); + assert_eq!(pthread_mutex_unlock(l as *mut pthread_mutex_t), 0); } pub unsafe fn wait(cond: uint, m: uint) { - assert_eq!(pthread_cond_wait(cond as *pthread_cond_t, m as *pthread_mutex_t), 0); + assert_eq!(pthread_cond_wait(cond as *mut pthread_cond_t, m as *mut pthread_mutex_t), 0); } pub unsafe fn signal(cond: uint) { - assert_eq!(pthread_cond_signal(cond as *pthread_cond_t), 0); + assert_eq!(pthread_cond_signal(cond as *mut pthread_cond_t), 0); } extern { @@ -224,19 +224,19 @@ mod imp { } extern { - fn pthread_mutex_init(lock: *pthread_mutex_t, + fn pthread_mutex_init(lock: *mut pthread_mutex_t, attr: *pthread_mutexattr_t) -> libc::c_int; - fn pthread_mutex_destroy(lock: *pthread_mutex_t) -> libc::c_int; - fn pthread_cond_init(cond: *pthread_cond_t, + fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> libc::c_int; + fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *pthread_condattr_t) -> libc::c_int; - fn pthread_cond_destroy(cond: *pthread_cond_t) -> libc::c_int; - fn pthread_mutex_lock(lock: *pthread_mutex_t) -> libc::c_int; - fn pthread_mutex_trylock(lock: *pthread_mutex_t) -> libc::c_int; - fn pthread_mutex_unlock(lock: *pthread_mutex_t) -> libc::c_int; + fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> libc::c_int; + fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> libc::c_int; + fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> libc::c_int; + fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> libc::c_int; - fn pthread_cond_wait(cond: *pthread_cond_t, - lock: *pthread_mutex_t) -> libc::c_int; - fn pthread_cond_signal(cond: *pthread_cond_t) -> libc::c_int; + fn pthread_cond_wait(cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t) -> libc::c_int; + fn pthread_cond_signal(cond: *mut pthread_cond_t) -> libc::c_int; } } @@ -263,7 +263,7 @@ mod imp { pub unsafe fn free_lock(h: uint) { DeleteCriticalSection(h as LPCRITICAL_SECTION); - libc::free(h as *c_void); + libc::free(h as *mut c_void); } pub unsafe fn free_cond(h: uint) {